home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / util / misc / Fudgit233.lha / Source / docs / reference.tmpl < prev    next >
Encoding:
Text File  |  1993-12-14  |  124.2 KB  |  4,551 lines

  1. @ifhelp
  2. ?
  3.  
  4.    F U D G I T   Version 2.33
  5.  
  6.  The three different modes are accessed by commands: 'fmode', 'pmode'
  7.  and 'cmode'. All fmode commands can be abbreviated down to 2
  8.  characters. Vectors have upper case name and scalar variables lower
  9.  case. A mix of both upper and lower cases results in forming a string
  10.  variable. Read the "Intro" help topic for an overview. See the
  11.  "README" help item for complete copyrights.
  12.  
  13.  Send bugs or comments to <isaac@physics.mcgill.ca>.
  14.  
  15. ?Intro
  16.  
  17.  FUDGIT is a double-precision multi purpose fitting program.
  18.  It can manipulate complete columns of numbers in the form
  19.  of vector arithmetic. FUDGIT is also an expression language
  20.  interpreter understanding most of C grammar except pointers.
  21.  It supports all functions from the C math library. Finally,
  22.  FUDGIT is a front end for any plotting program supporting
  23.  commands from stdin. It is a nice mathematical complement
  24.  to GNUPLOT, for example.
  25.  
  26.  The main features of FUDGIT are:
  27.     - Command shell including history;
  28.     - Possible abbreviation of all the ``fitting mode'' commands;
  29.     - Possible plural when it makes sense too;
  30.     - Interactive shell supporting flow control (while,
  31.       if-else-endif, foreach);
  32.     - User definable macros;
  33.     - User definable aliases;
  34.     - On-line help;
  35.     - On-line loadable procedure- or function-objects;
  36.     - On-line selectable plotting program;
  37.     - Fourier transforms;
  38.     - Smoothing;
  39.     - Double-precision built-in calculator;
  40.     - Built-in interpreter supporting most of C language including
  41.       flow control (if, else, while, for, break, continue);
  42.     - User definable functions and procedures;
  43.     - Double-precision vector arithmetic;
  44.     - Access to the complete C math library;
  45.     - Built-in fitting series such as:
  46.         + power series (polynomial);
  47.         + sine series;
  48.         + cosine series;
  49.         + Legendre polynomials;
  50.         + series of Gaussians;
  51.         + series of exponentials;
  52.     - User definable fitting functions;
  53.     - Totally dynamical allocation of variables and parameters;
  54.     - Possible selection of fitting ranges;
  55.  
  56.  FUDGIT has a collection of fitting routines including:
  57.     - straight line (linear) least squares;
  58.     - straight line (linear) least absolute deviation;
  59.     - general linear least squares using QR decomposition;
  60.     - general linear least squares using singular value decomposition;
  61.     - nonlinear Marquardt-Levenberg method;
  62.  
  63.  Refer to the ``User's Manual'' for a complete description and a
  64.  tutorial on I/O and fitting.
  65.  
  66.  See also:
  67.       Modes, C, cmode, fmode, pmode, fit, set, read, save, let
  68.  
  69. ?Modes
  70.  
  71.  FUDGIT is composed of three different modes. These modes can be
  72.  thought of as a C-shell like interpreter linked with a calculator,
  73.  sharing the same variables in memory, and with a plotting program of
  74.  our choice.
  75.  
  76.  The C-shell like interpreter is called the ``fitting mode''. It is
  77.  the central mode and is the one from which all accesses to the disk
  78.  are done. This mode has a range of commands allowing the user to read
  79.  vectors from or save vectors to a data file, to read a command script,
  80.  save the command history, do a Fourier transform of a vector, make a
  81.  linear or nonlinear least square fit, etc\ldots This mode also allows the
  82.  user to define macros and aliases, and to perform plotting-fitting
  83.  batch processes by using some of the built-in flow control commands
  84.  (while, foreach, if-else-endif). All the commands in the fitting mode
  85.  can be abbreviated. It is worth mentioning that in the fitting mode
  86.  the command line parsing is done by analyzing words separated by one
  87.  or more blanks (space or tab), as in an interactive csh.
  88.  
  89.  The ``C-calculator mode'' is a language interpreter supporting most of
  90.  C grammar except pointers. It also supports the complete
  91.  double-precision C math library. Thus, recognized keywords cannot be
  92.  abbreviated, and the different tokens need not be separated. Most of
  93.  the C operators and keywords are understood and a few extra operators
  94.  have been added. This mode does essentially all the possible
  95.  calculations on variables or vectors. Functions and procedures can be
  96.  defined. String variables, string comparison, addition, subtraction
  97.  are also supported by C-calculator mode. This mode is accessed by the
  98.  command `cmode'.
  99.  
  100.  Finally, the ``plotting mode'' is a channel talking directly to the
  101.  plotting program of your choice. Therefore, FUDGIT can serve as a
  102.  front end to any plotting program able to accept input from stdin.
  103.  This way, vectors can be build from the calculator and then plotted by
  104.  your favorite plotting program. The default plotting program is
  105.  GNUPLOT.
  106.  
  107. @endif
  108. @ifhelp
  109. ?\&
  110. @else
  111. \section{\&}
  112. @endif
  113.  
  114.  The `\&' operator forces \fudgit\ to use the built-in following fitting
  115.  mode command and to ignore any existing macro or alias with the same
  116.  name. This can be useful in constructions like:
  117. @ifhelp
  118.  
  119. @endif
  120. \nopagebreak\begin{verbatim}
  121.     macro cd 1
  122.         pmode cd "$1"
  123.         &cd $1                  # The built-in cd
  124.     stop
  125. \end{verbatim}
  126.  
  127. \Seealso
  128. \bq macro, cd \eq
  129.  
  130. @ifhelp
  131. ?\verb+\+
  132. @else
  133. \section{$\backslash$}
  134. @endif
  135.  
  136.  If anywhere in the middle of a line, a `\verb+\+' will indicate
  137.  \fudgit\ to take the following character as is. If at the end of a
  138.  line, a `\verb+\+' indicates that the present line continues on the
  139.  following one, and thus to ignore the following carriage return.
  140.  
  141. \Seealso
  142. \bq line editing\eq
  143.  
  144. @ifhelp
  145. ?!
  146. @else
  147. \section{!}
  148. @endif
  149.  
  150.  Any line beginning with the so-called bang operator `!' will execute
  151.  the system command line with a Bourne shell. Aliased commands as found
  152.  in your interactive C-shell do not hold any more. For example,
  153.  commands like {\tt !rm} will not be interactive (i.e. /bin/rm -i) even
  154.  if you have such an alias in your {\it .cshrc} file. Be careful!  A
  155.  nice turnaround is to alias rm to `{\tt ! rm -i}' in your {\it
  156.  .fudgitrc} file and to use the {\tt rm} command directly from
  157.  \fudgit's shell.
  158.  
  159.  When used in a macro name or an alias name, the `!' character has
  160.  still another meaning. This tells the parser that characters following
  161.  the `!' are optional. Therefore, if one types the following,
  162.  interactively, (see NOTE)
  163. @ifhelp
  164.  
  165. @endif
  166. \nopagebreak\begin{verbatim}
  167.      set noexpand
  168.      alias da!te !date
  169.      set expand
  170. \end{verbatim}
  171. @ifhelp
  172.  
  173. @endif
  174.  then the parser will recognize {\tt da}, {\tt dat} and {\tt date} as
  175.  all synonymous to the system command {\tt ! date} run through a Bourne
  176.  shell.
  177.  
  178.  NOTE: In interactive mode, the history functions will try to interpret
  179.  a history substitution if the `!' is not followed by a space. See the
  180.  appendices. To avoid that the line be scanned for a history event
  181.  designator, use the {\tt set noexpand} command. In some cases, it
  182.  might be simpler to use the {\tt system} command.
  183.  
  184. \Syntax
  185. \bq !{\it command}\eq
  186.  
  187. \Example
  188. \bq ! mail\eq
  189.  
  190. \Seealso
  191. \bq alias, ls, vi, foreach, system, set expand\eq
  192.  
  193. @ifhelp
  194. ?help?
  195. @else
  196. \section{?}
  197. @endif
  198.  
  199.  A question mark will indicate \fudgit\ to try to get the possible
  200.  options available to the command presently typed. This kind of help is
  201.  context sensitive and works when an insufficient number of arguments
  202.  is supplied. The question mark also serves as a wild character in
  203.  string subtraction.
  204.  
  205. \Syntax
  206. \bq {\it command} ? \eq
  207.  
  208. \Examples
  209. \bq ?\\
  210. show ?\\
  211. set function ?\eq
  212.  
  213. \Seealso
  214. \bq help, strings \eq
  215.  
  216. @ifhelp
  217. ?\$
  218. @else
  219. \section{\$}
  220. @endif
  221.  
  222.  The `\$' operator expands scalar variables or constants (double
  223.  precision numbers from C-calculator mode lookup table) as well as
  224.  string variables or constants. Existing scalar variables can thus be
  225.  expanded as a string in order to serve as a file name or directory
  226.  name, for example. The expansion is done according to the value given
  227.  to the {\tt set vformat} command which initially defaults to
  228.  ``\%.3g''. Using the scalar variable expansion operator in
  229.  C-calculator mode is not recommanded since a lot of precision might be
  230.  lost (actually it is a waste!). Scalar variable expansion is
  231.  essentially provided to allow alternative procedures in certain cases,
  232.  such as generating filenames from numbers. Math function {\tt scan}
  233.  can be considered as the complement of scalar variable expansion.
  234.  
  235.  The `\$' character also expands string variables. Expansion is done by
  236.  replacing the \${\it String-Variable-Name} by the value of the string
  237.  variable. This can be used to replace {\tt scan} in cases where the
  238.  string variable or constant represents a number. For example
  239. @ifhelp
  240.  
  241. @endif
  242. \nopagebreak\begin{verbatim}
  243.      foreach File in echo 2.2 4.4 6.7 8.32
  244.          let x = $File
  245.          .
  246.          .
  247.          .
  248.      end
  249. \end{verbatim}
  250.  
  251.  In both cases, if the variable name has to be followed by alphanumeric
  252.  characters, then the variable name can be delimited by braces as in
  253.  standard csh.
  254.  
  255.  Followed by an integer number, the `\$' character serves to designate
  256.  the arguments of a macro. Refer to the description of {\tt macro},
  257.  concerning this point.
  258.  
  259. \Syntax
  260. \bq \${\it name}\eq
  261. @ifhelp
  262.  
  263. @endif
  264.  or
  265. @ifhelp
  266.  
  267. @endif
  268. \bq\$\{{\it name}\}\eq
  269.  
  270. \Seealso
  271. \bq C, cmode, macro, echo, exit \eq
  272.  
  273. @ifhelp
  274. ?_dumplot
  275. @else
  276. \section{\_dumplot}
  277. @endif
  278.  
  279.  Command {\tt \_dumplot} is generally used in a macro to dump vectors
  280.  in the plotting pipe. It is described in more detail under {\tt
  281.  special} item.
  282.  
  283. @ifhelp
  284. ?_killplot
  285. @else
  286. \section{\_killplot}
  287. @endif
  288.  
  289.  Command {\tt \_killplot} is rarely used. It sends a KILL signal to the
  290.  plotting program. It is described in more detail under {\tt special}
  291.  item.
  292.  
  293. @ifhelp
  294. ?adjust
  295. @else
  296. \section{adjust}
  297. @endif
  298.  
  299.  The {\tt adjust} command is used to specify the parameters to be
  300.  adjusted in the ``least square linear'' and the ``Marquardt-Levenberg
  301.  nonlinear'' fitting methods. Parameters not being adjusted will have
  302.  their standard deviation set to zero.
  303.  
  304. \Syntax
  305. \bq adjust {\it index-list} \eq
  306.  
  307. \Example
  308. \bq adjust 1 2 4\eq
  309.  
  310. \Seealso
  311. \bq set parameters, set method, set function, fit, show fit \eq
  312.  
  313. @ifhelp
  314. ?alias
  315. @else
  316. \section{alias}
  317. @endif
  318.  
  319.  The {\tt alias} command is used to alias a multiple word command to a
  320.  single word. Although macros and aliases are different objects, it is
  321.  not allowed to define a macro and an alias with the same name since
  322.  aliases are always expanded first. Recall that the bang operator
  323.  (`!'), at the beginning of a line is recognized from a macro, an alias
  324.  or a script file so that an alias like
  325. @ifhelp
  326.  
  327. @endif
  328. \nopagebreak\begin{verbatim}
  329.      alias date !date
  330. \end{verbatim}
  331. @ifhelp
  332.  
  333. @endif
  334.  is perfectly legal. However, this would have to be typed
  335. @ifhelp
  336.  
  337. @endif
  338. \nopagebreak\begin{verbatim}
  339.      alias date ! date
  340. \end{verbatim}
  341. @ifhelp
  342.  
  343. @endif
  344.  at the interactive command line, to avoid that the `!' be interpreted
  345.  by the history functions.
  346.  
  347.  When called without arguments, {\tt alias} will list all the current
  348.  aliases. For obvious reasons, it is not allowed to {\tt alias} {\it
  349.  unalias}. {\tt alias} also supports the command abbreviation character
  350.  `!'. To enter a `!' without having it interpreted by the history
  351.  functions, just {\tt set noexpand} for the time entering the command.
  352.  When a `!' is part of the alias name this indicates that the alias
  353.  command name can be abbreviated down to that point. Since the {\tt \&}
  354.  operator is used to refer to the native commands, it is therefore
  355.  forbidden to start an alias name by character '\&'.
  356.  
  357. \Syntax
  358. \bq alias {\it command} {\it command-list} \eq
  359.  
  360. \Examples
  361. \nopagebreak\begin{verbatim}
  362.      alias mv !mv
  363.      alias . quit
  364.      alias da!te !date
  365. \end{verbatim}
  366.  
  367. \Seealso
  368. \bq !, \&, macro, unalias, set expand \eq
  369.  
  370. @ifhelp
  371. ?append
  372. @else
  373. \section{append and save}
  374. @endif
  375.  
  376.  The {\tt append} command can be used to append various things to an
  377.  existing file. If the file does not already exists, it will be
  378.  automatically created.
  379.  
  380.  The {\tt save} command can be used to save various things to a file.
  381.  If a file with the same name already exists, it will be overwritten
  382.  without any warning.
  383.  
  384. @ifhelp
  385. ?append history
  386. ?save history
  387. @else
  388. \subsection{append history}
  389. @endif
  390.  
  391.  History can be saved or appended to a file. Any file saved this way
  392.  can later be executed by the {\tt load} command. Note that {\tt append
  393.  history} will silently fail if the file does not exist.
  394.  
  395. \Syntax
  396. \bq append history {\it filename}\\
  397. save history {\it filename}\eq 
  398.  
  399. \Seealso
  400. \bq load, line editing, fmode \eq
  401.  
  402. @ifhelp
  403. ?append macros
  404. ?save macros
  405. @else
  406. \subsection{append macros}
  407. @endif
  408.  
  409.  All the current macros and aliases can be saved or appended to a file.
  410.  Any file saved this way can be subsequently {\tt load}ed at any time.
  411.  To avoid confusion between data files and script files we recommand
  412.  that you use the {\it .ft} extension for your script files.
  413.  
  414. \Syntax
  415. \bq append macros {\it filename}\\
  416. save macros {\it filename}\eq
  417.  
  418. \Seealso
  419. \bq alias, unalias, load, show, macro, unmacro \eq
  420.  
  421. @ifhelp
  422. ?append parameters
  423. ?save parameters
  424. @else
  425. \subsection{append parameters}
  426. @endif
  427.  
  428.  Parameters can be saved into a file at any time. The number output
  429.  format will be the one chosen by the {\tt set format} command. The
  430.  column order will be a parameter followed by its standard deviation.
  431.  All columns are separated by a tab. Therefore, if one has previously
  432.  set parameters, i.e.
  433. @ifhelp
  434.  
  435. @endif
  436. \nopagebreak\begin{verbatim}
  437.      set parameters MYPAR 3
  438.       .
  439.       .
  440.       .
  441.      save parameters myfile
  442. \end{verbatim}
  443. @ifhelp
  444.  
  445. @endif
  446.  then there will be 6 columns as follows:
  447. @ifhelp
  448.  
  449. @endif
  450. \nopagebreak\begin{verbatim}
  451. MYPAR[1]    DMYPAR[1]       . . .      MYPAR[3]     DMYPAR[3]
  452. \end{verbatim}
  453. @ifhelp
  454.  
  455. @endif
  456.  in file {\it myfile}. Most of the time, the user will desire to
  457.  save parameters along with some variables or constants. This can be
  458.  done by giving the variable or constant (either string or scalar)
  459.  names on the command line. For example,
  460. @ifhelp
  461.  
  462. @endif
  463. \nopagebreak\begin{verbatim}
  464.      let t = 0.23
  465.      set parameters A 2
  466.      .
  467.      .
  468.      .
  469.      save parameters t parfile
  470. \end{verbatim}
  471. @ifhelp
  472.  
  473. @endif
  474.  will create a file {\it parfile} containing the value of scalar
  475.  variable {\tt t}, followed by the 2 values of parameters {\tt A},
  476.  alternated with the value of their standard deviations {\tt DA}.
  477.  Note that the given list of variables will be printed first.
  478.  
  479. \Syntax
  480. \bq append parameters {\it variable-list\optio} {\it filename}\\
  481. save parameters {\it variable-list\optio} {\it filename}\eq
  482.  
  483. \Seealso
  484. \bq set format, set parameters, show parameters\eq
  485.  
  486. @ifhelp
  487. ?append variables
  488. ?save variables
  489. @else
  490. \subsection{append variables}
  491. @endif
  492.  
  493.  Any variable or number of variables can be saved to a file at any
  494.  time. Vector elements referenced by an explicit index are considered
  495.  as variables. String variables and constants are recognized as well.
  496.  
  497. \Syntax
  498. \bq append variables {\it variable-list} {\it filename} \\
  499. save variables {\it variable-list} {\it filename}\eq
  500.  
  501. \Examples
  502. \nopagebreak\begin{verbatim}
  503.      append variables x Y[3] a VECTOR[78] datafile1
  504.      save variables t PARAM[2] DPARAM[2] datafile2
  505. \end{verbatim}
  506.  
  507. \Seealso
  508. \bq load, cmode, let, C, show, auto \eq
  509.  
  510. @ifhelp
  511. ?append vectors
  512. ?save vectors
  513. @else
  514. \subsection{append vectors}
  515. @endif
  516.  
  517.  Any vector or number of vectors can be saved to a file. All the values
  518.  are written in columns separated by a tab. The number format will be
  519.  the one chosen by the {\tt set format} command.
  520.  
  521. \Syntax
  522. \bq append vectors {\it VECTOR-list} {\it filename}\\
  523. save vectors {\it VECTOR-list} {\it filename}\eq
  524.  
  525. \Examples
  526. \nopagebreak\begin{verbatim}
  527.     append vectors X Y ERROR1 TEST2 datafile1
  528.     save vectors TIME TEMP DT datafile2
  529. \end{verbatim}
  530.  
  531. \Seealso
  532. \bq set format, set data, read, fit, fft, show, auto \eq
  533.  
  534. @ifhelp
  535. ?auto
  536. @else
  537. \section{auto}
  538. @endif
  539.  
  540.  The {\tt auto} keyword is used to define automatic variables. The type
  541.  of variable can be a scalar variable, a VECTOR or a String, depending
  542.  on the upper-lower case letters in the variable name. The scope of
  543.  auto variables is delimited by braces as in C. All auto variables are
  544.  stored on the stack and are freed when the scope of the variable is
  545.  left. Definition of variables can only be done right after a brace has
  546.  been opened. Only scalar variables can be assigned as the are defined,
  547.  while vectors are assigned to zero, and strings are empty. Contrarily
  548.  to C, automatic scalar variables are set to zero if not assigned.
  549.  {\tt auto} is a C-calculator mode keyword.
  550.  
  551. \Syntax
  552. \bq auto {\it var-list} \eq
  553.  
  554. \Examples
  555. \nopagebreak\begin{verbatim}
  556.      # Some dummy examples
  557.      set data 100
  558.      cmode
  559.         x = y = 1                # These (x, y) are global
  560.         X = y++                  # As well as vector X
  561.         { auto x=2, X, Y         # All these variables are local...
  562.            X=3; Y=sin(x)
  563.             .
  564.             .
  565.             .
  566.         }                        # ...and stop existing here
  567.         x                        # This x still contains 1
  568.      # An example with a procedure
  569.         proc test(x) {
  570.            auto y=2
  571.            z = x + y++           # This z is global
  572.         }
  573.      fmode
  574. \end{verbatim}
  575.  
  576. \Seealso
  577. \bq C, cmode, func, proc\eq
  578.  
  579. @ifhelp
  580. ?break
  581. @else
  582. \section{break}
  583. @endif
  584.  
  585.  The {\tt break} keyword is used as in C to break C-calculator mode
  586.  {\tt for} or {\tt while} loops. {\tt break} is a C-calculator mode
  587.  command.
  588.  
  589. \Syntax
  590. \bq break \eq
  591.  
  592. \Seealso
  593. \bq C, continue, cmode, for, while \eq
  594.  
  595. @ifhelp
  596. ?C
  597. @else
  598. \section{C}
  599. @endif
  600.  
  601.  The following gives a brief description of the supported C-calculator
  602.  syntax and differences with standard C.
  603.  
  604.  The following operators are recognized, in order of precedence:
  605. @ifhelp
  606.  
  607. @endif
  608. \nopagebreak\begin{verbatim}
  609.     ++, --                          (post and pre) increment-decrement
  610.     -, !                            unary minus and logical NOT
  611.     ^                               exponentiation, right associative
  612.     /, *, %                         division, multiplication, modulo
  613.     +, -                            addition, subtraction
  614.     >, >=, <, <=, ==, !=            relational operators
  615.     &&                              logical AND
  616.     ||                              logical OR
  617.     =, +=, -=, /=, *=               assignments, right associative
  618. \end{verbatim}
  619.  
  620.  All operators are left associatives except those specified.
  621.  They are all common to C except for the exponentiation operator.
  622.  
  623.  The following keywords are reserved tokens:  {\tt auto, if, else, while,
  624.  for, break, continue}, and {\tt return}, plus two extra keywords {\tt
  625.  proc, func}. They roughly obey the same syntax as in C so that statements
  626.  like:
  627.  
  628. \bq if ({\it conditions})\\
  629.     {\it cmode-line-statement}\eq
  630. @ifhelp
  631.  
  632. @endif
  633.  or
  634. @ifhelp
  635.  
  636. @endif
  637. \bq if ({\it conditions}) {\it cmode-line-statement} \eq
  638. @ifhelp
  639.  
  640. @endif
  641.  or
  642. @ifhelp
  643.  
  644. @endif
  645. \bq if ({\it conditions}) \{\\
  646.      {\it cmode-statements}\\
  647. \}\eq
  648.  
  649.  The same thing is true for the else constructions {\tt else} of which
  650.  some examples follow:
  651.  
  652. \bq if ({\it conditions}) \\
  653.     {\it cmode-line-statement}\\
  654. else\\
  655.     {\it cmode-line-statement}\eq
  656. @ifhelp
  657.  
  658. @endif
  659.  or
  660. @ifhelp
  661.  
  662. @endif
  663. \bq if ({\it conditions}) \{\\
  664.     {\it cmode-statements}\\
  665. \} else \{\\
  666.     {\it cmode-statements}\\
  667. \}\eq
  668.  
  669.  Here {\it cmode-line-statement} means any semicolon separated list
  670.  of C-calculator mode statements typed on the same line. Since
  671.  semicolons are separators and not terminators, empty statements are
  672.  defined by empty braces {\tt \{ \}}.
  673.  
  674.  The {\tt return} keyword must have parentheses when returning a value
  675.  from a function as in {\tt return(x * sin(y))}. A single {\tt return}
  676.  will only be recognized from within a procedure.
  677.  
  678.  To avoid potential confusion with variables, keywords cannot be
  679.  abbreviated.
  680.  
  681.  As opposed to C, there exists no integer in the C-calculator mode. All
  682.  scalar variables and numbers are double precision. This means that
  683.  logical true is 1.0 and false is 0.0. As in C, one must be careful
  684.  with comparison operators. The C {\tt switch} syntax is not supported
  685.  (would require integers).
  686.  
  687.  As an extension, string comparison is possible with the equality
  688.  operators `==' and `!='. This will return true or false if the string
  689.  variables (or constants) are identical or not. Assignments of string
  690.  variables actually copies all characters of the string on the RHS to
  691.  the string variable on the LHS. String additions and subtractions are
  692.  also possible.
  693.  
  694.  Function and procedure definitions are defined with prototypes, i.e.,
  695.  a list of variables representing the proper kind of variable. At
  696.  run-time, the arguments of the function are checked for type
  697.  compatibility and for their number.
  698.  
  699.  All variables are global except automatic variables defined using the
  700.  {\tt auto} keyword. 
  701.  
  702. \Seealso
  703. \bq cmode, let, math, scan, strings, auto \eq
  704.  
  705. @ifhelp
  706. ?cd
  707. @else
  708. \section{cd}
  709. @endif
  710.  
  711.  The {\tt cd} command changes the working directory. Called with no
  712.  argument, {\tt cd} will bring you to your \$HOME directory. Note that
  713.  {\tt cd} changes the current working directory of \fudgit\ only.
  714.  Therefore, your plotting program will still be in the previous
  715.  directory. To get around this difficulty, you only have to define a
  716.  macro as follows, if your plotting program supports {\tt cd}:
  717. @ifhelp
  718.  
  719. @endif
  720. \nopagebreak\begin{verbatim}
  721.      macro Cd 1
  722.          pmode cd "$1"
  723.          &cd $1
  724.      stop
  725.      alias cd Cd
  726. \end{verbatim}
  727.  
  728. \Syntax
  729. \bq cd {\it filename\optio}\eq
  730.  
  731. \Examples
  732. \nopagebreak\begin{verbatim}
  733.      cd
  734.      cd /nazgul/users/fulano
  735. \end{verbatim}
  736.  
  737. \Seealso
  738. \bq \&, pwd, alias\eq
  739.  
  740. @ifhelp
  741. ?cmode
  742. @else
  743. \section{cmode}
  744. @endif
  745.  
  746.  The {\tt cmode} command allows you to go in the C-calculator mode. The
  747.  only way to come back to the main fitting mode is by using the {\tt
  748.  fmode} command or to type \^{ }D in interactive mode. Commands cannot
  749.  be abbreviated in {\tt cmode}. Parallel to the {\tt cmode} command,
  750.  the {\tt let} command can be used to pass one single command, or
  751.  command line to mathematical parser. To be consistent with {\tt pmode}
  752.  command, {\tt cmode} also accepts arguments in which case it is
  753.  equivalent to the {\tt let} command. It is not an error to call {\tt
  754.  cmode} from the C-calculator mode. A warning message will be given
  755.  though.
  756.  
  757. \Syntax
  758. \bq cmode {\it command-list\optio}\eq
  759.  
  760.  The C-calculator mode supports most of C syntax (see item C), and most
  761.  of the C math library. Thus, the following functions are supported:
  762. @ifhelp
  763.  
  764. @endif
  765. \nopagebreak\begin{verbatim}
  766.     trigo:    hyperbolic:  expo:    special:   conversion:  random:
  767.  
  768.     cos()     cosh()       ln()      besy0()    trunc()     srand()
  769.     cot()     coth()       log()     besy1()    floor()     rand()
  770.     csc()     csch()       exp()     besj0()    ceil()
  771.     sec()     sech()       sqrt()    besj1()    rint()
  772.     sin()     sinh()       cbrt()    besjn()    abs()
  773.     tan()     tanh()                 besyn()    int()
  774.     acos()   acosh()                 erf()      scan()
  775.     asin()   asinh()                 erfc()     min()
  776.     atan()   atanh()                 lgamma()   max()
  777.     atan2()                          interp()   sum()
  778.                                                 vread()
  779. \end{verbatim}
  780.  
  781.  Any upper case variable (possibly including `\_') possibly mixed with
  782.  digits will be recognized as a vector, e.g., {\tt TEMP\_2, TEST, D},
  783.  etc. Any lower case name will be taken as a scalar variable, e.g.,
  784.  {\tt x, t4}, etc. There are two predefined constants, {\tt pi} $=\pi$
  785.  and {\tt e}$=e$, which should not be unlocked and modified. As well,
  786.  the built-in constant {\tt data} contains the current size of the
  787.  vectors and can be modified through the {\tt set data} command, by the
  788.  {\tt read}/{\tt exec} commands, or by {\tt unlock}ing the constant and
  789.  modifying it directly. The built-in constant {\tt chi2} contains the
  790.  value of $\chi^2$ as obtained from the latest fit. And finally, the
  791.  built-in scalar constant {\tt param} contains the number of parameters
  792.  as defined by {\tt set parameters}.
  793.  
  794.  A mix of upper case and lower case letters will serve to indicate a
  795.  string variable. Strings values are indicated by double quotes as in
  796.  C. Unlike C, \fudgit\ considers strings as self-contained objects that
  797.  can be added, subtracted, and checked for (in)equality. Thus, string
  798.  objects (i.e. string variables, string constants and string values)
  799.  can: serve as argument to {\tt scan} function; be part of string
  800.  assignment statements or of a truth statement involving (in)equality
  801.  operator; be added (concatenated using the `+' operator) one with
  802.  another; be subtracted (remove string termination using the `-'
  803.  operator) one with another; and finally be argument of string
  804.  functions.
  805.  
  806.  A predefined string constant called {\tt Tmp} contains the string
  807.  "/tmp/fudgitPID" where PID is the process id number of the current
  808.  process. This file, and any file belonging to you, whose name starts
  809.  with the same string, will be erased automatically by the {\tt exit}
  810.  or {\tt quit} commands. This string is typically used by the {\tt
  811.  gnuplot} macro in order to pass data to the \gnuplot\ plotting program
  812.  which cannot read data from standard input. Another predefined string
  813.  constant is {\tt ReadFile} which contains the last data filename that
  814.  has been loaded. Finally, the string constant {\tt Cwd} is made
  815.  available in order to get the current working directory.
  816.  
  817.  The following table contains all the built-in constants.
  818. @ifhelp
  819.  
  820. @endif
  821. \nopagebreak\begin{verbatim}
  822.     chi2               Value of chi^2 from the last fit;
  823.     data               Length of all vectors (< samples) as set by set data;
  824.     e                  Neperian number;
  825.     param              Number of parameters as set by set parameters;
  826.     pi                 Guess this one;
  827.  
  828.     Cwd                Current working directory;
  829.     ReadFile           The last file (program) read by read (exec);
  830.     Tmp                A temporary filename "/tmp/fudgitPID";
  831. \end{verbatim}
  832.  
  833.  Constants (either strings and scalars) can also be created by {\tt
  834.  lock}ing a variable. In the same manner, a constant can be modified
  835.  directly if it has been {\tt unlock}ed.
  836.  
  837.  The algebraic operations applicable to scalar variables can be applied
  838.  to vectors. Vector algebra can be mixed with scalar variable algebra
  839.  in which case the user has to take the implied loop into account. For
  840.  example, although the following operation is not standard C
  841.  programming:
  842. @iftex
  843. \footnote
  844. @else
  845.  
  846. @endif
  847.  {NOTE: In order to show that some commands can be typed from both
  848.  C-calculator mode and the fitting fmode, the following examples shows
  849.  the typing mode from the first line. However, one can always type the
  850.  same C-calculator mode command from the fitting mode by using the {\tt
  851.  let} command (or {\tt cmode} command).}
  852. @ifhelp
  853.  
  854. @endif
  855. \nopagebreak\begin{verbatim}
  856.      cmode
  857.          x = 0
  858.          X = x++
  859. \end{verbatim}
  860. @ifhelp
  861.  
  862. @endif
  863.  will define a vector $X$ of size {\tt data} (see {\tt set data})
  864.  ranging from $X[1]$ to $X[data]$ and taking values from 0 to
  865.  $data-1$. Multiple commands can be given with the separator `;', for
  866.  example, another version of the previous command could be written
  867. @ifhelp
  868.  
  869. @endif
  870. \nopagebreak\begin{verbatim}
  871.      cmode
  872.          x=0;X=++x
  873. \end{verbatim}
  874. @ifhelp
  875.  
  876. @endif
  877.  in which case a vector $X$ taking values from 1 to $data$ will be
  878.  created. (Note that the latter uses a pre-increment whereas the
  879.  former uses a post-increment operator on {\tt x}: results are thus
  880.  different). Vector elements can be referenced by elements using
  881.  standard C grammar. Therefore, the same vector could be created by
  882.  using a {\tt while} construction as in:
  883. @ifhelp
  884.  
  885. @endif
  886. \nopagebreak\begin{verbatim}
  887.      fmode
  888.      set data 1000
  889.      let X=0;i=0
  890.      cmode
  891.          while (i++ <= data)
  892.             X[i] = i
  893.      fmode
  894. \end{verbatim}
  895. @ifhelp
  896.  
  897. @endif
  898.  or, using a {\tt for} loop, 
  899. @ifhelp
  900.  
  901. @endif
  902. \nopagebreak\begin{verbatim}
  903.      cmode
  904.         for (x=0;x<=data;x++) {
  905.             X[x] = x
  906.         }
  907.      fmode
  908. \end{verbatim}
  909.  
  910.  Noninteger variables will be truncated to the nearest lower integer to
  911.  form a vector index.
  912. @ifhelp
  913.  
  914. @endif
  915. \nopagebreak\begin{verbatim}
  916.      cmode
  917.          y= 2.01
  918.          x=2.23; X[2]=Z[y]+5^x 
  919. \end{verbatim}
  920.  
  921.  Assigning a vector to a constant will assign all the elements to that
  922.  constant.
  923. @ifhelp
  924.  
  925. @endif
  926. \nopagebreak\begin{verbatim}
  927.      fmode
  928.      let X = pi
  929.      let Z2 = 0
  930. \end{verbatim}
  931.  
  932.  The C-calculator checks for undefined variables on the RHS of any
  933.  assignment. From C-calculator mode, variables values can be seen by
  934.  typing the variable name by itself or by using the {\tt print}
  935.  command, if the output is selected to be {\it stdout}. From the
  936.  fitting mode, contents of constants and variables (either strings or
  937.  scalars) is displayed using {\tt show variables} command, or by using
  938.  the `\$' expansion operator. However, vectors can be only be seen from
  939.  the fitting mode by using the {\tt show vector} command.
  940.  
  941.  Each unknown vector name given on the command line allocates a vector
  942.  of {\tt sample} size.
  943.  
  944.  To be a calculator as such, the C-calculator prints the value of the
  945.  expression given on the command line. Thus, the statement
  946. @ifhelp
  947.  
  948. @endif
  949. \nopagebreak\begin{verbatim}
  950.      cmode
  951.          x + 2
  952. \end{verbatim}
  953. @ifhelp
  954.  
  955. @endif
  956.  will print the value of $x + 2.0$. The contents of many variables can
  957.  be displayed at the same time by giving a coma separated list such as
  958.  in
  959. @ifhelp
  960.  
  961. @endif
  962. \nopagebreak\begin{verbatim}
  963.      cmode
  964.          x,"temperature", t
  965. \end{verbatim}
  966. @ifhelp
  967.  
  968. @endif
  969.  where the string {\it temperature} will be printed between the values
  970.  of variables $x$ and $t$. Note that the C-calculator mode recognizes
  971.  strings by double quotes. Special characters such as '\verb+\n+' are
  972.  also legal in a string.
  973.  
  974.  We conclude by giving some examples involving string variables:
  975. @ifhelp
  976.  
  977. @endif
  978. \nopagebreak\begin{verbatim}
  979.      fmode
  980.      let String = "new.file"
  981.      let x = (String == "new.file")
  982.      let y = ("file1" == "file2")
  983.      let Bing = "\a\a\a"
  984.      let Here = Cwd        # Store the value of the current working directory
  985.      let Input = Read()                       # Read from stdin
  986.      let Test = FileName(ReadFile) - ".data"
  987.      let Dir = DirName(InputFile)
  988.      let y = scan(Read(), "%lf")
  989.      let File = "STRING_23.4"
  990.      let number = scan("%*[_A-Z]%lf", File)
  991.      let Message = "A tab \t and a newline\n"
  992. \end{verbatim}
  993. @ifhelp
  994.  
  995. @endif
  996.  where the truth statement could be legally used as a condition for an
  997.  {\tt if}, a {\tt while}, or a {\tt for}.
  998.  
  999. \Seealso
  1000. \bq let, C, data, func, proc, print, fmode, math, while, for, return,\\
  1001. auto, if, break, samples, quotes, strings\eq
  1002.  
  1003. @ifhelp
  1004. ?comments
  1005. @else
  1006. \section{comments}
  1007. @endif
  1008.  
  1009.  By default, anything following a `{\tt \#}' will be treated as a
  1010.  comment and ignored. This holds for data files as well as for command
  1011.  script files loaded with the {\tt load} command. This default can be
  1012.  changed with the {\tt set comment} command. Sometimes a comment
  1013.  character needs to be taken literally in a script file. The comment
  1014.  character will be accepted as data if it follows the `\verb+\+' escape
  1015.  operator, i.e. `\verb+\+\#', or, in the fitting mode only, whenever the
  1016.  comment character is somewhere inside quotes or parentheses. The
  1017.  comment character is always accepted literally when typed on the
  1018.  interactive command line.
  1019.  
  1020. \Seealso
  1021. \bq set comment, read, load, show comment, exec \eq
  1022.  
  1023. @ifhelp
  1024. ?continue
  1025. @else
  1026. \section{continue}
  1027. @endif
  1028.  
  1029.  The {\tt continue} keyword has the same usage it has in C for sending
  1030.  the control to the next iteration of a {\tt for} or {\tt while} loop.
  1031.  {\tt continue} is a C-calculator mode command.
  1032.  
  1033. \Syntax
  1034. \bq continue \eq
  1035.  
  1036. \Seealso
  1037. \bq for, while, cmode, C \eq
  1038.  
  1039. @ifhelp
  1040. ?datafiles
  1041. @else
  1042. \section{data files}
  1043. @endif
  1044.  
  1045.  Files containing data are loaded by specifying the name of the data
  1046.  file to the {\tt read} command. Data files should contain one data
  1047.  point per line. A data point can be a 256 dimensional object. By
  1048.  default, anything following character `{\tt \#}' will be treated as
  1049.  comment and ignored. In all cases, the numbers on each line of a data
  1050.  file must be separated by any number of blank spaces or tabs. These
  1051.  blanks divide each line into columns. Thus, \fudgit\ can handle up to
  1052.  256 columns per line. Warning will be given if a line has a different
  1053.  number of columns. Strings such as {\it NaN} or {\it Infinity} are
  1054.  recognized and refused. The default compilation gives a maximum line
  1055.  size of 1024 characters.
  1056.  
  1057. \Seealso
  1058. \bq read, exec, set comment \eq
  1059.  
  1060. @ifhelp
  1061. ?echo
  1062. @else
  1063. \section{echo}
  1064. @endif
  1065.  
  1066.  The {\tt echo} command allows the user to print a string to the
  1067.  standard output. If no argument is given {\tt echo} will only print a
  1068.  newline. This command can be used to display a message or, when
  1069.  coupled with the variable expansion operator `\$', to see the value of
  1070.  a printable (either string or scalar) variable defined in the
  1071.  C-calculator.
  1072.  
  1073. \Syntax
  1074. \bq echo {\it string-list}\eq
  1075.  
  1076. \Examples
  1077. \nopagebreak\begin{verbatim}
  1078.       echo Starting the fit
  1079.       echo $Mydir
  1080. \end{verbatim}
  1081.  
  1082. \Seealso
  1083.       \bq cmode, \$ \eq
  1084.  
  1085. @ifhelp
  1086. ?else
  1087. @else
  1088. \section{else}
  1089. @endif
  1090.  
  1091.  The {\tt else} keyword is used in {\tt if} constructions, both in
  1092.  C-calculator anf fitting modes. Refer to the {\tt if} entries for a
  1093.  complete description.
  1094.  
  1095. @ifhelp
  1096. ?end
  1097. @else
  1098. \section{end}
  1099. @endif
  1100.  
  1101.  The {\tt end} command is used to complete a {\tt foreach} loop or a
  1102.  {\tt while} loop. Keyword {\tt end} is also used to tell {\tt read}
  1103.  that we are finished writing data to stdin. This command should always
  1104.  be found on a line by itself (comments are allowed though).
  1105.  
  1106. \Seealso \bq foreach, while, read, stop\eq
  1107.  
  1108. @ifhelp
  1109. ?endif
  1110. @else
  1111. \section{endif}
  1112. @endif
  1113.  
  1114.  The {\tt endif} command is used to complete an {\tt if} construction
  1115.  in fitting mode. Keyword {\tt endif} must always be used on a line by
  1116.  itself (comments are allowed though). Refer to the {\tt if} entries
  1117.  for a the complete description.
  1118.  
  1119. @ifhelp
  1120. ?environment
  1121. @else
  1122. \section{environment}
  1123. @endif
  1124.  
  1125.  \fudgit\ is sensitive to the following environment variables:
  1126.  
  1127.     $\bullet$ PAGER for the program called to format long listings.
  1128.  
  1129.     $\bullet$ HOME for the directory to which {\tt cd} defaults.
  1130.  
  1131.     $\bullet$ SHELL for the shell called by {\tt system} when this
  1132.           latter is called without arguments.
  1133.  
  1134.  If not defined, the default pager is {\it /usr/?/more} (path depends
  1135.  on system) and the default shell {\it /bin/csh}.
  1136.  
  1137. \Seealso
  1138. \bq cd, system, show vectors, help \eq
  1139.  
  1140. @ifhelp
  1141. ?exec
  1142. @else
  1143. \section{exec}
  1144. @endif
  1145.  
  1146.  The command {\tt exec} executes a program and reads data from it. It
  1147.  supports the same syntax {\tt read} does except that the program name
  1148.  replaces the file name. A program is a program name or anything that
  1149.  can be typed in a shell. If the command line has more than one string,
  1150.  it must be glued with quotes. On a successful call, {\tt exec} will
  1151.  set the string constant {\tt ReadFile} to the name of the program
  1152.  which generated the data.
  1153.  
  1154. \Syntax
  1155. \bq exec {\it commands} {\it assignment$[$range$]$\optio} \ldots\eq
  1156.  
  1157. \Examples
  1158. \nopagebreak\begin{verbatim}
  1159.      exec simulate X:1 Y:2[0:200]
  1160.      exec "cat data | myfilter -g" X1:1[0:*] X2:2 X3:4
  1161. \end{verbatim}
  1162.  
  1163. \Seealso
  1164. \bq read, comments\eq
  1165.  
  1166. @ifhelp
  1167. ?exit
  1168. @else
  1169. \section{exit}
  1170. @endif
  1171.  
  1172.  The commands {\tt exit} and {\tt quit} will exit \fudgit.
  1173.  See details under item {\tt quit}.
  1174.  
  1175. \Syntax
  1176. \bq exit\eq
  1177.  
  1178. \Seealso
  1179. \bq quit, cmode \eq
  1180.  
  1181. @ifhelp
  1182. ?fft
  1183. @else
  1184. \section{fft}
  1185. @endif
  1186.  
  1187.  The {\tt fft} command will take the Fourier transform of the specified
  1188.  vectors and put the real part in a vector specified by the third
  1189.  argument. The imaginary part will be put in a vector specified by the
  1190.  fourth argument. Input vectors can be used for output. The resulting
  1191.  vectors will contain frequencies ranging from 0 to $N/2$ followed by
  1192.  $-(N/2 - 1)$ to $-1$ in units of $1/(N*\Delta)$ where $\Delta$ is the
  1193.  sampling rate. If a real vector is transformed $h(t) -> H(f)$, we
  1194.  should have $H(-f) = H^*(f)$. Therefore, with $H = R + iI$ and
  1195.  $H^* = R - iI$ be the transformed vectors, we should have
  1196.  $R(-f) = R(f)$ and $I(-f) = -I(f)$, where $f$ is discrete and ranges
  1197.  as mentioned above. In terms of vector indices, these relations
  1198.  become $R[i] = R[N-i+2]$ and $I[i] = -I[N-i+2]$ for $1 < i < N/2$ in
  1199.  addition to the fact that $I[1] = I[(N/2)+1] = 0$. Therefore, because
  1200.  the negative frequency part is the mirror image of the positive one,
  1201.  it is common to plot only the positive frequencies of the Fourier
  1202.  transform of a real vector. This can be done by reducing {\tt data} to
  1203.  half its value.
  1204.  
  1205.  Because of the use of a FFT algorithm, the number of data points must
  1206.  be an integer power of 2. If not, the user should pad the vector with
  1207.  zeros up to the next largest power of two. Each transform is
  1208.  normalized by the factor $\sqrt{(N)}$ so that {\tt fft RE IM T\_RE T\_IM}
  1209.  followed by {\tt invfft T\_RE T\_IMA RE2 IMA2} will not introduce a
  1210.  factor $N$ in vectors {\tt RE2} and {\tt IMA2} (i.e., {\tt RE} = {\tt RE2}
  1211.  and {\tt IM} = {\tt IM2}). At his choice, the user can use the
  1212.  C-calculator functionality in order to implement windowing.
  1213.  
  1214.  The power spectrum can be obtained from:
  1215. @ifhelp
  1216.  
  1217. @endif
  1218. \nopagebreak\begin{verbatim}
  1219.       fft RE IMA T_RE T_IMA
  1220.       let POW = T_RE^2 + T_IMA^2
  1221. \end{verbatim}
  1222. @ifhelp
  1223.  
  1224. @endif
  1225.  where $POW[i]$ will contain the power value associated with frequency $f$,
  1226.  which goes from 0 to $N/2$ followed by $-(N/2 - 1)$ to $-1$ (in units
  1227.  of $1/(N*\Delta)$) as $i$ goes from 1 to $N$.
  1228.  
  1229. \Syntax
  1230. \bq fft {\it real-VECTOR} {\it ima-VECTOR} {\it real-VECTOR} {\it ima-VECTOR}\eq
  1231.  
  1232. \Examples
  1233. \nopagebreak\begin{verbatim}
  1234.       # real vector X
  1235.       let IM=0
  1236.       # re-use IM vector for output
  1237.       fft X IM Z IM
  1238.       # complex vectors X+iY where i = sqrt(-1) transformed in V+iW  
  1239.       fft X Y V W
  1240. \end{verbatim}
  1241.  
  1242. \Seealso
  1243. \bq invfft, smooth, cmode, let, read, math, data \eq
  1244.  
  1245. @ifhelp
  1246. ?fit
  1247. @else
  1248. \section{fit}
  1249. @endif
  1250.  
  1251.  The {\tt fit} command is used to fit a function, chosen by {\tt set
  1252.  function}, to a pair of vectors containing the independent and
  1253.  dependent variables. Depending on the type of fit, selected by the
  1254.  {\tt set method} command, a third vector containing the standard
  1255.  deviation might be required. {\tt fit} allocates a vector having the
  1256.  name of the dependent variable appended with the string {\tt FIT}.
  1257.  This vector contains the computed values of the function for the given
  1258.  independent vector. Depending on the method, the built-in constant
  1259.  {\tt chi2} will contain the value of the mean square deviation
  1260.  weighted by vector {\it $\sigma$-VECTOR} or the mean absolute deviation.
  1261.  
  1262. \Syntax
  1263. \bq fit {\it independent-VECTOR} {\it dependent-VECTOR} {\it $\sigma$-VECTOR}\eq
  1264.  
  1265. \Example
  1266. \nopagebreak\begin{verbatim}
  1267.      fit X Y DY
  1268. \end{verbatim}
  1269. @ifhelp
  1270.  
  1271. @endif
  1272.  will create a vector {\tt YFIT} containing the value of the fitted
  1273.  function for each of the values of the independent vector {\tt X}.
  1274.  Note that the standard deviation is required for most fitting routines
  1275.  since it is used to weigh the value of local square deviation from the
  1276.  fit (in fact, this is the definition of $\chi^2$). If {\it
  1277.  $\sigma$-VECTOR} is unavailable just use
  1278. @ifhelp
  1279.  
  1280. @endif
  1281. \nopagebreak\begin{verbatim}
  1282.      let DY=1
  1283. \end{verbatim}
  1284. @ifhelp
  1285.  
  1286. @endif
  1287.  using the previous example. This simply gives the same weight to all
  1288.  data points.
  1289.  
  1290. \Seealso
  1291. \bq set method, set function, show fit, show parameters, append\eq
  1292.  
  1293. @ifhelp
  1294. ?fmode
  1295. @else
  1296. \section{fmode}
  1297. @endif
  1298.  
  1299.  The {\tt fmode} command allows you to return to the fitting mode, when
  1300.  the program is in one of the C-calculator or plotting modes. The
  1301.  fitting mode, is the main mode of the program. The two other modes are
  1302.  the C-calculator mode, accessed by the {\tt cmode} command, and the
  1303.  plotting mode, accessed by the {\tt pmode} command. When used
  1304.  interactively, \^{ }D returns to the fitting mode from either of the
  1305.  C-calculator mode or from the plotting mode. It is not an error to
  1306.  call {\tt fmode} from the fitting mode. A warning message will be
  1307.  given though.
  1308.  
  1309. \Syntax
  1310. \bq fmode\eq
  1311.  
  1312. \Seealso
  1313. \bq cmode, pmode, let\eq
  1314.  
  1315. @ifhelp
  1316. ?for
  1317. @else
  1318. \section{for}
  1319. @endif
  1320.  
  1321.  The {\tt for} command is a C-calculator mode command. It behaves
  1322.  roughly like a standard C {\tt for} construction. In interactive
  1323.  mode, any new input line will be prompted with a ``n\{\ldots n\verb+\t+''
  1324.  where `n' stands for the nesting level and `\verb+\t+' for a tab.
  1325.  Keyword {\tt for} is a C-calculator mode command.
  1326.  
  1327. \Syntax
  1328. \bq for ({\it init-expressions}; {\it cond-expressions}; {\it loop-expressions}) \\
  1329.       {\it cmode-line-statement}\eq
  1330. @ifhelp
  1331.  
  1332. @endif
  1333.  or 
  1334. @ifhelp
  1335.  
  1336. @endif
  1337. \bq for ({\it init-expressions}; {\it cond-expressions}; {\it loop-expressions}) \{\\
  1338.       {\it cmode-statements}\\
  1339. \}\eq
  1340.  
  1341. \Examples
  1342. \nopagebreak\begin{verbatim}
  1343.      cmode
  1344.          for (i=1,j=2;i+j <= data; i+=2,j+=3) A[i] = X[j]
  1345.      fmode
  1346.      # Another example:
  1347.      # A macro to remove point x in a vector. Syntax: delete "vector" "index"
  1348.      macro delete 2
  1349.          cmode
  1350.              for(i=$2;i<data;i++) {
  1351.                  $1[i] = $1[i+1]
  1352.              }
  1353.          fmode
  1354.          unlock data
  1355.          let data--
  1356.          lock data
  1357.      stop
  1358. \end{verbatim}
  1359.  
  1360. \Seealso
  1361. \bq C, break, continue, cmode, if, set data, func, proc, if, lock, math \eq
  1362.  
  1363. @ifhelp
  1364. ?foreach
  1365. @else
  1366. \section{foreach}
  1367. @endif
  1368.  
  1369.  The {\tt foreach} command loops through the strings obtained from a
  1370.  given \unix\ command. Wild card characters are allowed since
  1371.  everything following the {\tt in} keyword is passed to a Bourne shell
  1372.  for execution. Strings can be obtained from any program including the
  1373.  easiest cases {\it echo, ls} and {\it cat}. The variable name must be
  1374.  of string type, i.e., consisting of both upper case and lower case
  1375.  letters (and possibly \_'s and digits).
  1376.  
  1377. \Syntax
  1378. \bq foreach {\it StringVarName} in {\it \unix-command}\\
  1379.      {\it body of the loop}\\
  1380. end\eq
  1381.  
  1382. \Example
  1383. \nopagebreak\begin{verbatim}
  1384.      #convert columns 2 and 3 of the following files in log-log format
  1385.      foreach Fname in ls data*.7[0-9] datatest.42 data*.8[4-7]
  1386.          echo $Fname ...
  1387.          read $Fname X:2[0.001:*] Y:3[0.001:*]
  1388.          let X = log(X)
  1389.          let Y = log(Y)
  1390.          save vectors X Y $Fname.log
  1391.      end
  1392. \end{verbatim}
  1393.  
  1394. \Seealso
  1395. \bq for, math function scan, while, macro \eq
  1396.  
  1397. @ifhelp
  1398. ?free
  1399. @else
  1400. \section{free}
  1401. @endif
  1402.  
  1403.  The command {\tt free} is made available for memory management. It is
  1404.  used to free vectors, variables, functions, procedures, and numbers
  1405.  that were allocated in the C-calculator mode.
  1406.  
  1407.  When called with the special argument ``@all'', {\tt free} will erase
  1408.  all the user vectors, numbers and variables, as well as all active
  1409.  functions and procedures (not macros and aliases). Otherwise, {\tt free}
  1410.  will free the specified vector(s) or variable(s). Constants (either
  1411.  scalar or string) cannot be removed without first unlocking them.
  1412.  
  1413. \Syntax
  1414. \bq free {\it VECTOR- or variable-list} \\
  1415. free @all\eq
  1416.  
  1417. \Examples
  1418. \nopagebreak\begin{verbatim}
  1419.       free @all
  1420.       free X y TEMP
  1421. \end{verbatim}
  1422.  
  1423. \Seealso
  1424. \bq unlock, C, cmode, show table, show memory, samples, let \eq
  1425.  
  1426. @ifhelp
  1427. ?func
  1428. @else
  1429. \section{func}
  1430. @endif
  1431.  
  1432.  The {\tt func} command defines a function. A function is distinct from
  1433.  a procedure from the fact that a function must return a value whereas
  1434.  a procedure must not. Arguments are given in the definition with any
  1435.  name prototype representative of the data type. As in C, the argument
  1436.  list must be comma separated when calling the function (after having
  1437.  defined it). An example follows. {\tt func} is a C-calculator mode
  1438.  command.
  1439.  
  1440.  The prototype list defines the type of variable to be used. Although
  1441.  all global variables are accessible from within the function,
  1442.  variables are always searched for from the prototype list first, then
  1443.  from the local list ({\tt auto} variables), and finally from the
  1444.  global list. All scalar variables are passed by value: thus any scalar
  1445.  expression is legal as scalar argument. String arguments and vector
  1446.  arguments are passed by pointer: thus string and vector arguments must
  1447.  refer to a variable explicitly. The {\tt show table} can be used to
  1448.  list all the installed objects at a given time.
  1449.  
  1450. \Syntax
  1451. \bq func {\it functionname}({\it proto-list\optio}) {\it cmode-line-statement}; return({\it value})\eq
  1452. @ifhelp
  1453.  
  1454. @endif
  1455.  or
  1456. @ifhelp
  1457.  
  1458. @endif
  1459. \bq func {\it functionname}({\it proto-list\optio}) \{\\
  1460.      {\it cmode-statements}\\
  1461.      return({\it value})\\
  1462. \}\eq
  1463.  
  1464. \Examples
  1465. \nopagebreak\begin{verbatim}
  1466.     # The following example will print the factorial of all integers up to 120.
  1467.     cmode
  1468.         func fac(x) {  # This `x' is a prototype: it does not exist.
  1469.             if (x <= 0)  {
  1470.                return(1)
  1471.             } else {
  1472.                return(x * fac(--x))
  1473.             }
  1474.        }
  1475.        x=1  # This `x' is a global scalar variable
  1476.        while (x<120) {
  1477.            fac(x++)
  1478.        }
  1479.     fmode
  1480.     # The following calculates the average of a vector
  1481.     cmode
  1482.         func avg(X) {
  1483.             auto i,x
  1484.  
  1485.             for (x=0,i=1;i<=data;i++) {
  1486.                 x += X[i]
  1487.             }
  1488.             return(x/data)
  1489.         }
  1490.     fmode
  1491. \end{verbatim}
  1492.  
  1493. \Seealso
  1494. \bq C, return, for, while, cmode, math, free, proc, show table, install \eq
  1495.  
  1496. @ifhelp
  1497. ?help
  1498. @else
  1499. \section{help}
  1500. @endif
  1501.  
  1502.  The {\tt help} command displays on-line help. To specify information on a
  1503.  particular topic use the syntax:
  1504.  
  1505. \bq help {\it topic}\eq
  1506.  
  1507.  If {\it topic} is not specified, a short message is displayed about
  1508.  \fudgit. Topic names can be abbreviated down to the shortest
  1509.  unambiguous string. In case of doubt, {\tt help} will print out all
  1510.  possible completions. Thus, {\tt help f} will print all help topics
  1511.  starting with the letter `f'. After help for the requested topic has
  1512.  been given, help for a subtopic may be requested by typing the
  1513.  subtopic name, extending the help request. After that subtopic help
  1514.  has been displayed, the request may be extended again, or pressing
  1515.  return will return one level back to the previous topic. Eventually,
  1516.  the fitting mode prompt will return.
  1517.  
  1518. \Seealso
  1519. \bq help? \eq
  1520.  
  1521. @ifhelp
  1522. ?history
  1523. @else
  1524. \section{history}
  1525. @endif
  1526.  
  1527.  The {\tt history} command lists all the previous command lines, along
  1528.  with a number. History lines can be called using the !{\it string}
  1529.  construction or the !{\it number}. History is only available in
  1530.  interactive mode. See Appendix A for more details.
  1531.  
  1532. \Syntax \bq history\eq
  1533.  
  1534. \Seealso
  1535. \bq append history, line editing \eq
  1536.  
  1537. @ifhelp
  1538. ?if
  1539. @else
  1540. \section{if}
  1541. @endif
  1542.  
  1543.  There are two kinds of {\tt if} constructions available in \fudgit,
  1544.  one in the fitting mode and the other in the C-calculator mode.
  1545.  
  1546. @ifhelp
  1547. ?if cmode_style
  1548. @else
  1549. \subsection{C-calculator mode if}
  1550. @endif
  1551.  
  1552.  In C-calculator mode, {\tt if} and {\tt else} are reserved keywords.
  1553.  C-calculator mode {\tt if} construction is similar to the one in
  1554.  standard C. Note that {\it cmode-statements} refers to any sequence of
  1555.  C-calculator mode commands and that {\it cmode-line-statement} refers
  1556.  to a semicolon separated list of C-calculator mode commands typed on
  1557.  the same line.
  1558.  
  1559. \Syntax
  1560. \bq if ({\it conditions}) {\it cmode-line-statement}\eq
  1561. @ifhelp
  1562.  
  1563. @endif
  1564.  or
  1565. @ifhelp
  1566.  
  1567. @endif
  1568. \bq if ({\it conditions})\\
  1569.     {\it cmode-line-statement}\eq
  1570. @ifhelp
  1571.  
  1572. @endif
  1573.  or
  1574. @ifhelp
  1575.  
  1576. @endif
  1577. \bq if ({\it conditions}) \{\\
  1578.      {\it cmode-statements}\\
  1579. \}\eq
  1580. @ifhelp
  1581.  
  1582. @endif
  1583.  or, using the {\tt else} constructions,
  1584. @ifhelp
  1585.  
  1586. @endif
  1587. \bq if ({\it conditions})\\
  1588.      {\it cmode-line-statement}\\
  1589. else\\
  1590.      {\it cmode-line-statement}\eq
  1591. @ifhelp
  1592.  
  1593. @endif
  1594.  or, for statements on more than one line,
  1595. @ifhelp
  1596.  
  1597. @endif
  1598. \bq if ({\it conditions}) \{\\
  1599.      {\it cmode-statements}\\
  1600. \} else if ({\it conditions}) \{\\
  1601.      {\it cmode-statements}\\
  1602. \} else \{\\
  1603.      {\it cmode-statements}\\
  1604. \}\eq
  1605.  
  1606. \Seealso
  1607. \bq C, cmode \eq
  1608.  
  1609. @ifhelp
  1610. ?if fmode-style
  1611. @else
  1612. \subsection{Fitting mode if}
  1613. @endif
  1614.  
  1615.  Fitting mode {\tt if} has a syntax very similar to the one in C-shell.
  1616.  It requires the keywords {\tt then} and {\tt endif} and supports {\tt
  1617.  else} constructions. The difference resides in the fact that the
  1618.  conditional statement has to follow C-calculator mode grammar and
  1619.  syntax and thus has a richer set of operators. The `\$' expansion
  1620.  operator is therefore not needed in the conditional statement, as it
  1621.  is in C-shell conditional statements. All active variables, constants,
  1622.  and their string counterparts, are directly available to the
  1623.  conditional statement. Note that the {\it fmode-statements} can also
  1624.  contain C-calculator mode commands (even possibly including
  1625.  C-calculator mode {\tt if}'s!).
  1626.  
  1627. \Syntax
  1628. \bq if ({\it conditions}) then\\
  1629.      {\it fmode-statements}\\
  1630. endif\eq
  1631. @ifhelp
  1632.  
  1633. @endif
  1634.  or, using the {\tt else} constructions,
  1635. @ifhelp
  1636.  
  1637. @endif
  1638. \bq if ({\it conditions}) then\\
  1639.      {\it fmode-statements}\\
  1640. else if ({\it conditions}) then\\
  1641.      {\it fmode-statements}\\
  1642. else\\
  1643.      {\it fmode-statements}\\
  1644. endif\eq
  1645.  
  1646. \Seealso
  1647. \bq while, foreach, macro\eq
  1648.  
  1649. @ifhelp
  1650. ?in
  1651. @else
  1652. \section{in}
  1653. @endif
  1654.  
  1655.  The {\tt in} keyword is required in {\tt foreach} constructions in
  1656.  fitting mode. Refer to the latter for details.
  1657.  
  1658. @ifhelp
  1659. ?install
  1660. @else
  1661. \section{install}
  1662. @endif
  1663.  
  1664.  The {\tt install} command dynamically loads defined routines from an
  1665.  object file. The user decides on the internal name of the routine but
  1666.  the internal name must consist of lower case letters only. The object
  1667.  file is an object compiled by the C or FORTRAN compiler. On IRIX, the
  1668.  object must be compiled with the option {\tt -G 0} given to either the
  1669.  C or FORTRAN compiler. The {\it rtn-name} is the name of one of the
  1670.  procedure(s) or function(s) the user wants to install from the
  1671.  object file. The routine will be installed as {\it name} and as a
  1672.  procedure (not returning value) or as a function (returning value)
  1673.  depending on the name separator being a {\tt :} (colon) or a {\tt =}
  1674.  (equal sign) respectively. (See example below).
  1675.  
  1676.  NOTE: This option is only available on IRIX and SUNOS for the moment.
  1677.  
  1678.  The external routine must expect pointers to double for all its
  1679.  arguments. Thus, all arguments are passed by pointers except that
  1680.  pointers to variables do not point to the variables as such but to a
  1681.  temporary copy of them. This allows us to have expressions like
  1682.  
  1683.  {\tt f = mycall(X, sin(x) + 1, data)}
  1684.  
  1685.  for which the value {\tt sin(x) + 1} must necessarily be a temporary copy.
  1686.  In this example, the prototype is a function {\tt mycall(VEC, expr, expr)}.
  1687.  We shall consider an example in more detail below. All arguments are
  1688.  strongly typed as vector, parameter, expression or string. Prototyping
  1689.  is done using the uppercase-lowercase convention. Parameters are prototyped
  1690.  using the word {\tt PARAM} or less (e.g. {\tt PAR}).
  1691.  
  1692.  On IRIX, the linker will create a binary file built from the module
  1693.  name and with the extension {\it file}.{\tt ld}. This binary is the
  1694.  one that will be loaded in memory. Time stamps are included so that
  1695.  {\tt ld(1)} will not be called if not necessary. These files are not
  1696.  erased at exit, since they are reusable and prevent the linker to be
  1697.  called if nothing changed between two sessions of \fudgit.
  1698.  
  1699.  Successive calls of {\tt install} with the same module should not be
  1700.  done unless the same functions and procedures are reinstalled. If this
  1701.  is the case, the user should then reinstall the same modules (that
  1702.  could have been modified and recompiled in the mean time) using the
  1703.  {\tt reinstall} command. If a module is reinstalled with different
  1704.  routines or function or procedure names, the previously defined
  1705.  functions or procedures might not be properly installed anymore and
  1706.  calling them might result in an undefined behavior.
  1707.  
  1708.  The file {\it fudgit.h} describes the functions user-defined programs
  1709.  can linked with. Among other things, these functions allow the user to
  1710.  have elegant error handling and exit.
  1711.  
  1712.  The {\tt show table} command can be used to list all the installed
  1713.  objects at a given time.
  1714.  
  1715.  A file having the same base name of the module but with the extension
  1716.  {\it libs} can be put in the same directory in order to include extra
  1717.  libraries while loading the module. On IRIX, these extra libraries
  1718.  must all contain objects compiled with the flag {\it -G 0} (see {\tt
  1719.  cc(1)}).  (For example, some IRIX systems have a -lm\_G0 math
  1720.  library.) User-defined libraries can be specified along with system
  1721.  libraries. A typical example could be a line like:
  1722.  
  1723. \bq /home/myname/myproject/libmyG0.a /usr/lib/libmG0.a \eq
  1724.  
  1725.  for linking with user's library {\it /home/myname/myproject/libmyG0.a}.
  1726.  Equivalently, for non-IRIX systems, loading a FORTRAN object might
  1727.  require something like this:
  1728.  
  1729. \bq /usr/lib/libF77.a /usr/lib/libm.a \eq
  1730.  
  1731.  Library names can be on multiple lines. However, the file cannot have
  1732.  more than 1024 bytes. A `{\tt \#}' found anywhere in this file will make
  1733.  the rest of the file to be ignored.
  1734.  
  1735.  Note that when loading FORTRAN code, the user must append an underscore
  1736.  to the routine name so that {\tt install} or {\tt reinstall} can find it.
  1737.  
  1738.  The IRIX version does not fully support incremental linking, i.e., to
  1739.  use, in an object to be installed, symbols that were defined in
  1740.  previously {\tt install}ed objects. However, all the symbols contained
  1741.  in the original \fudgit\ executable remain at all time available to
  1742.  all linked routines. Therefore, IRIX users should make sure that
  1743.  external objects are self-contained and only reference to external
  1744.  routines that are intrinsic to \fudgit\ or come directly (and once)
  1745.  from linked libraries at installation time.
  1746.  
  1747. \Syntax
  1748. \bq install {\it object-file} {\it rtn-name}[:|=]{\it name}(arg-list)\ldots\eq
  1749.  
  1750. \Example
  1751. \nopagebreak\begin{verbatim}
  1752.     hostname: cat mymodule.c
  1753.         #include <math.h>
  1754.         #include "fudgit.h"
  1755.         
  1756.         /* An example of a user-defined routine inversing the order of an even
  1757.          * vector. Typical call would be:
  1758.          *  myproc(A_VEC, data)
  1759.          * from C-calculator mode. NOTE that both VEC and expr are pointers.
  1760.          * To make things explicit, fudgit.h contains a few typedef's.
  1761.          */
  1762.         
  1763.         void myproc(X, dn)
  1764.         VEC X;
  1765.         expr dn;
  1766.         {
  1767.             int i, half_n;
  1768.             int n = (int)*dn;  /* note that dn is a pointer to a double */
  1769.             double tmp;
  1770.     
  1771.             if (n%2 == 1)   /* report error if odd number (Why not?)*/
  1772.                 Ft_matherror("%s: Called with an odd number %d.", "myproc", n);
  1773.  
  1774.             /* You have full use of math and stdio libraries too!!! */
  1775.             fprintf(stderr,
  1776.             "BTW, Did you know that %lf is the sqrt(pi)?\n", sqrt(M_PI));
  1777.  
  1778.             half_n = n >>1;  /* half of n */
  1779.             for (i=0;i<half_n;i++) { /* Standard C: indices from 0 to data-1 */
  1780.                 tmp = X[i];
  1781.                 X[i] = X[n-i];
  1782.                 X[n-i] = tmp;
  1783.             }
  1784.         }
  1785.         
  1786.         /* 
  1787.          * Another example involving a function. The following calculates the
  1788.          * non-normalized correlation between vectors A and B as defined by 
  1789.          * corr(A, B) = <A*B> - <A> * <B>
  1790.          *
  1791.          */
  1792.         
  1793.         double myfunc(A, B, dn)
  1794.         VEC A, B;
  1795.         expr dn;
  1796.         {
  1797.             int i, n = (int)*dn;  /* Again, dn is a pointer to a double */
  1798.             double sumA, sumB, sumAB;
  1799.         
  1800.             sumA = sumB = sumAB = 0.0;
  1801.             /* sum up the values of interest */    
  1802.             for (i=0;i<n; i++) {  /* indices go from 0 to data-1 */
  1803.                 sumA += A[i];
  1804.                 sumB += B[i];
  1805.                 sumAB += A[i] * B[i];
  1806.             }
  1807.             /* leave it simple */
  1808.             sumA /= *dn;
  1809.             sumB /= *dn;
  1810.             sumAB /= *dn;
  1811.         
  1812.             return (sumAB - sumA*sumB);
  1813.         }
  1814.     hostname: cc -G 0 -O -c mymodule.c
  1815.     hostname: cat loadex.ft
  1816.         # This is an example for loading
  1817.         # Install function myfunc as corr() and procedure myproc as inverse()
  1818.         # Prototypes are made from any name representing the proper type:
  1819.         install mymodule.o myproc:inverse(V, n) myfunc=corr(V, V, n)
  1820.         set data 24
  1821.         let x=1;X=x++
  1822.         let Y=sin(X)
  1823.         cmode
  1824.             # Inverse order of vector X
  1825.             inverse(X, data)
  1826.             # Calculate correlation between X and Y
  1827.             y=corr(X, Y, data)
  1828.             # Print its value
  1829.             "correlation:", y
  1830.         fmode
  1831.     hostname: fudgit loadex.ft
  1832.     install: myproc installed as procedure inverse.
  1833.     install: myfunc installed as function corr.
  1834.     BTW, Did you know that 1.772454 is the sqrt(pi)?
  1835.     correlation: 9.20717026e-01 
  1836. \end{verbatim}
  1837.  
  1838.  When linking FORTRAN functions or subroutines, the user must append an
  1839.  underscore after every function or subroutine name. All argument
  1840.  variables and vectors have to be defined {\tt double precision} as
  1841.  well as returning functions. Typical examples are included in the
  1842.  distribution in the {\it tools} directory.
  1843.  
  1844. \Seealso
  1845. \bq C, cmode, show table, func, proc \eq
  1846.  
  1847. @ifhelp
  1848. ?invfft
  1849. @else
  1850. \section{invfft}
  1851. @endif
  1852.  
  1853.  Command {\tt invfft} performs the inverse Fourier transform of the
  1854.  given vectors. It assumes that the frequencies are ordered from 0 to
  1855.  $N/2$ followed by negative frequencies ranging from $-(N-1)/2$ to $-1$
  1856.  in units of $1/(N*\Delta)$ where $\Delta$ is the sampling interval.
  1857.  The results are normalized by a factor $1/\sqrt{(N)}$ so that a
  1858.  transform followed by an inverse transform should give the original
  1859.  vector. The resulting vectors are stored in the third and fourth
  1860.  arguments. Thus, {\tt invfft X Y V W} inverse transforms X+iY into
  1861.  V+iW. Input vectors can be used as output vectors. See {\tt fft} for
  1862.  more details.
  1863.  
  1864. \Syntax
  1865. \bq invfft {\it real-VECTOR} {\it ima-VECTOR} {\it real-VECTOR} {\it ima-VECTOR}\eq
  1866.  
  1867. \Seealso
  1868. \bq fft, smooth, cmode, let, read, math, data \eq
  1869.  
  1870. @ifhelp
  1871. ?let
  1872. @else
  1873. \section{let}
  1874. @endif
  1875.  
  1876.  The {\tt let} command opens the door to the C-calculator mode from the
  1877.  fitting mode, but leaves the program in fitting mode. All the {\tt
  1878.  let} commands can always be typed directly from the C-calculator mode
  1879.  without having to prepend with the {\tt let} keyword. The converse is
  1880.  also true; all the commands given in C-calculator mode could be typed
  1881.  from the fitting mode by prepending them with the {\tt let} command.
  1882.  Although {\tt let} is typed from the fitting mode, the remainder of
  1883.  the line is parsed according to C-calculator mode rules, and thus
  1884.  quotes are no longer swallowed. Variable expansion operator `\$' is
  1885.  still recognized, but its use is not recommanded for C-calculator
  1886.  statements. See `\$' for more details on this point.
  1887.  
  1888. \Syntax
  1889. \bq let {\it C-calculator-mode-commands}\eq
  1890.  
  1891. \Examples
  1892. \nopagebreak\begin{verbatim}
  1893.       # generate the zero order first kind bessel
  1894.       # function between (0, 2*pi]
  1895.       fmode
  1896.       set data 2000
  1897.       let x=1; X=x++
  1898.       let tmp = 2*pi/data     # compute sequence only once
  1899.       let X *= tmp
  1900.       let Y = besj0(X)
  1901. \end{verbatim}
  1902.  
  1903. \Seealso
  1904. \bq cmode, C, math \eq
  1905.  
  1906. @ifhelp
  1907. ?editing
  1908. ?line
  1909. @else
  1910. \section{line editing and history}
  1911. @endif
  1912.  
  1913.  The command shell supports line editing and history. The editing
  1914.  commands are based on the basic \emacs\ commands. A short summary
  1915.  follows but a more complete description can be found in Appendix B.
  1916.  
  1917.  Line editing:
  1918.  
  1919.  $\bullet$ \^{ }B moves back a single character.
  1920.  
  1921.  $\bullet$ \^{ }F moves forward a single character.
  1922.  
  1923.  $\bullet$ \^{ }A moves to the beginning of the line.
  1924.  
  1925.  $\bullet$ \^{ }E moves to the end of the line.
  1926.  
  1927.  $\bullet$ \^{ }H and DEL delete the previous character.
  1928.  
  1929.  $\bullet$ \^{ }D deletes the current character.
  1930.  
  1931.  $\bullet$ \^{ }K deletes from current position to the end of line.
  1932.  
  1933.  $\bullet$ \^{ }L,\^{ }R redraws line in case it gets trashed.
  1934.  
  1935.  $\bullet$ \^{ }U deletes the entire line.
  1936.  
  1937.  $\bullet$ \^{ }W deletes the last word.
  1938.  
  1939.  History:
  1940.  
  1941.  $\bullet$ \^{ }P moves back through history.
  1942.  
  1943.  $\bullet$ \^{ }N moves forward through history.
  1944.  
  1945.  $\bullet$ !!   previous command.
  1946.  
  1947.  $\bullet$ !\$  previous command last argument.
  1948.  
  1949.  $\bullet$ !{\it string}  last command starting with {\it string}.
  1950.  
  1951.  Completion:
  1952.  
  1953.  $\bullet$ tab complete command if first arg, filename otherwise.
  1954.  
  1955.  $\bullet$ esc-? or double tab list possible completions.
  1956.  
  1957.  Each line of input must be smaller than 1024 bytes which is more than
  1958.  sufficient for most applications. Lines can be continued on several
  1959.  lines provided carriage returns follow a `\verb+\+' (as in standard
  1960.  shells).
  1961.  
  1962. \Seealso
  1963. \bq append history, \$, history\eq
  1964.  
  1965. @ifhelp
  1966. ?load
  1967. ?source
  1968. @else
  1969. \section{load}
  1970. @endif
  1971.  
  1972.  The {\tt load} command executes each line of the specified input file
  1973.  as if it had been typed in interactively. Files created by the {\tt
  1974.  save history} command can be {\tt load}ed directly. Text files
  1975.  containing valid commands can be created and then executed by the {\tt
  1976.  load} command. Files being {\tt load}ed may themselves contain {\tt
  1977.  load} commands. See {\tt comment} for information about comments in
  1978.  command scripts. The {\tt load} command is recursive so it can be
  1979.  nested. The only limitation is the I/O stack which has a default
  1980.  capacity of 32. This value can be easily changed at compilation time
  1981.  of the program.
  1982.  
  1983.  The current working directory always returns to the value in effect
  1984.  before the loaded script was called. This is valid for nested {\tt
  1985.  load} commands too.
  1986.  
  1987.  In order to avoid confusion between data files and script files we
  1988.  strongly recommand you to stick to the conventional {\it .ft} extension
  1989.  for your script files.
  1990.  
  1991. \Syntax
  1992. \bq load {\it filename.ft}\eq
  1993.  
  1994.  A {\tt load} command is also performed implicitly on any filenames
  1995.  given as arguments to {\tt fudgit}, when called from your \unix\
  1996.  session. These are loaded and executed in the order specified, and
  1997.  then \fudgit\ exits.
  1998.  
  1999. \Seealso
  2000. \bq set comment, exec, startup, append history, append macros \eq
  2001.  
  2002. @ifhelp
  2003. ?lock
  2004. ?constant
  2005. @else
  2006. \section{lock}
  2007. @endif
  2008.  
  2009.  Variables can be turned into constants using the {\tt lock} command.
  2010.  Once a variable is {\tt lock}ed, any assignment trying to change its
  2011.  value will result in a parsing error. This is valid for both scalar
  2012.  and string variables. It is not an error to try to lock a constant. A
  2013.  warning message will be given though. However, trying to lock an
  2014.  unexisting variable or something else than a constant or variable will
  2015.  result in an error.
  2016.  
  2017. \Syntax
  2018. \bq lock {\it var-list}\eq
  2019.  
  2020. \Seealso
  2021. \bq C, cmode, unlock \eq
  2022.  
  2023. @ifhelp
  2024. ?ls
  2025. @else
  2026. \section{ls}
  2027. @endif
  2028.  
  2029.  The command {\tt ls} calls ``/bin/ls -FC''. If any arguments are
  2030.  given, those are passed to ``/bin/ls -FC''. Wild card characters are
  2031.  possible since expansion is done by a Bourne shell.
  2032.  
  2033. \Syntax
  2034. \bq ls {\it ls-argument-list}\eq
  2035.  
  2036. \Examples
  2037. \nopagebreak\begin{verbatim}
  2038.       ls p* test?
  2039.       ls -l datafile
  2040.       ls -l *.data
  2041. \end{verbatim}
  2042.  
  2043. \Seealso
  2044. \bq system, alias \eq
  2045.  
  2046. @ifhelp
  2047. ?macro
  2048. @else
  2049. \section{macro}
  2050. @endif
  2051.  
  2052.  The {\tt macro} command allows the user to define macros. Macros can
  2053.  be embedded, but another macro cannot be defined from within a macro,
  2054.  mainly because of their common way to refer to arguments. The name of
  2055.  the macro followed by the number of arguments required must be given.
  2056.  The maximum number of arguments a macro can have is 16. An exclamation
  2057.  mark in the macro name will indicate that the macro name can be
  2058.  abbreviated and that the characters following the exclamation point
  2059.  are optional. Macros are only recognized in the fitting mode. The
  2060.  total length of each macro is limited to 2048 bytes in size. Macros
  2061.  can be nested to a maximum of 32. Macros are only recognized from the
  2062.  fitting mode.
  2063.  
  2064. \Syntax
  2065. \bq macro {\it macroname} {\it argument-number}\\
  2066.     {\it body of the macro}\\
  2067. stop\eq
  2068.  
  2069. \Example
  2070. \nopagebreak\begin{verbatim}
  2071.      # define a macro named fpl!ot (o, t, are optional)
  2072.      # requiring 3 arguments . Uses the plotting program gnuplot.
  2073.      # Syntax: fplot X Y YFIT
  2074.      # plot X Y with data points and X YFIT with solid line
  2075.      macro fpl!ot 3
  2076.          # save vectors in temp file (will be automatically removed on exit)
  2077.          save vec $1 $2 $3 $Tmp.fplot
  2078.          # plot second column with points and third with line
  2079.          pmode plot '$Tmp.fplot' us 1:2 wi point, \
  2080.             '$Tmp.fplot' us 1:3 wi line
  2081.      stop
  2082. \end{verbatim}
  2083.  
  2084. \Seealso
  2085. \bq append macros, show macros, load, startup, unmacro, alias, unalias \eq
  2086.  
  2087. @ifhelp
  2088. ?math
  2089. @else
  2090. \section{math functions}
  2091. @endif
  2092.  
  2093.  The C-calculator mode math functions found in \fudgit\ are very close
  2094.  to the corresponding functions found in the \unix\ math library. Some
  2095.  other functions, not found in the math library, are also part of
  2096.  \fudgit. Most of the numerically unstable functions (i.e. ln, log,
  2097.  exp,\ldots) check for both an argument out of range and a value out of
  2098.  domain at each call. All math functions are double precision and can
  2099.  only be called from the C-calculator mode, or by using the {\tt let}
  2100.  command from the fitting mode. These functions are also available in
  2101.  the conditional statements of the fitting mode {\tt if} and {\tt
  2102.  while}, since these statements are C-calculator mode statements,
  2103.  although part of fitting mode constructions.
  2104.  
  2105. @ifhelp
  2106. ?math abs
  2107. ?abs
  2108. @else
  2109. \subsection{math function abs}
  2110. @endif
  2111.  
  2112.  The {\tt abs()} function returns the absolute value of its argument. 
  2113.  
  2114. @ifhelp
  2115. ?math acos
  2116. ?acos
  2117. @else
  2118. \subsection{math function acos}
  2119. @endif
  2120.  
  2121.  The {\tt acos()} function returns the arc cosine (inverse cosine) of
  2122.  its argument. {\tt acos()} returns its argument in radians.
  2123.  
  2124. @ifhelp
  2125. ?math acosh
  2126. ?acosh
  2127. @else
  2128. \subsection{math function acosh}
  2129. @endif
  2130.  
  2131.  The {\tt acosh()} function returns the positive (principal) hyperbolic
  2132.  arc cosine (inverse cosine) of its argument.
  2133.  
  2134. @ifhelp
  2135. ?math asin
  2136. ?asin
  2137. @else
  2138. \subsection{math function asin}
  2139. @endif
  2140.  
  2141.  The {\tt asin()} function returns the arc sine (inverse sine) of its
  2142.  argument. {\tt asin()} returns its argument in radians.
  2143.  
  2144. @ifhelp
  2145. ?math asinh
  2146. ?asinh
  2147. @else
  2148. \subsection{math function asinh}
  2149. @endif
  2150.  
  2151.  The {\tt asinh()} function returns the hyperbolic arc sine (inverse
  2152.  sine) of its argument.
  2153.  
  2154. @ifhelp
  2155. ?math atan
  2156. ?atan
  2157. @else
  2158. \subsection{math function atan}
  2159. @endif
  2160.  
  2161.  The {\tt atan()} function returns the arc tangent (inverse tangent) of
  2162.  its argument. {\tt atan()} returns its argument in radians.
  2163.  
  2164. @ifhelp
  2165. ?math atan2
  2166. ?atan2
  2167. @else
  2168. \subsection{math function atan2}
  2169. @endif
  2170.  
  2171.  The {\tt atan2(y, x)} function returns the arc tangent (inverse
  2172.  tangent) of the ratio of its arguments $(y/x)$. {\tt atan2()} returns
  2173.  its argument in radians. The signs of $y$ and $x$ are used to
  2174.  determine the quadrant.
  2175.  
  2176. @ifhelp
  2177. ?math atanh
  2178. ?atanh
  2179. @else
  2180. \subsection{math function atanh}
  2181. @endif
  2182.  
  2183.  The {\tt atanh()} function returns the hyperbolic arc tangent (inverse
  2184.  tangent) of its argument.
  2185.  
  2186. @ifhelp
  2187. ?math besj0
  2188. ?besj0
  2189. @else
  2190. \subsection{math function besj0}
  2191. @endif
  2192.  
  2193.  The {\tt besj0()} function returns the j0th Bessel function of its
  2194.  argument, i.e it returns the zero$^{th}$ order Bessel function of the
  2195.  first kind. {\tt besj0()} expects its argument to be in radians.
  2196.  
  2197. @ifhelp
  2198. ?math besj1
  2199. ?besj1
  2200. @else
  2201. \subsection{math function besj1}
  2202. @endif
  2203.  
  2204.  The {\tt besj1()} function returns the j1st Bessel function of its
  2205.  argument, i.e it returns the first order Bessel function of the first
  2206.  kind. {\tt besj1()} expects its argument to be in radians.
  2207.  
  2208. @ifhelp
  2209. ?math besjn
  2210. ?besjn
  2211. @else
  2212. \subsection{math function besjn}
  2213. @endif
  2214.  
  2215.  The {\tt besjn(n, x)} function returns the jnst Bessel function of its
  2216.  argument, i.e it returns the $n^{th}$ order Bessel function of the
  2217.  first kind. {\tt besjn()} expects its second argument to be in
  2218.  radians.
  2219.  
  2220. @ifhelp
  2221. ?math besy0
  2222. ?besy0
  2223. @else
  2224. \subsection{math function besy0}
  2225. @endif
  2226.  
  2227.  The {\tt besy0()} function returns the y0th Bessel function of its
  2228.  argument, i.e it returns the zero$^{th}$ order Bessel function of the
  2229.  second kind. {\tt besy0()} expects its argument to be in radians.
  2230.  
  2231. @ifhelp
  2232. ?math besy1
  2233. ?besy1
  2234. @else
  2235. \subsection{math function besy1}
  2236. @endif
  2237.  
  2238.  The {\tt besy1()} function returns the y1st Bessel function of its
  2239.  argument, i.e it returns the first order Bessel function of the second
  2240.  kind. {\tt besy1()} expects its argument to be in radians.
  2241.  
  2242. @ifhelp
  2243. ?math besyn
  2244. ?besyn
  2245. @else
  2246. \subsection{math function besyn}
  2247. @endif
  2248.  
  2249.  The {\tt besyn(n, x)} function returns the ynst Bessel function of its
  2250.  argument, i.e it returns the $n^{th}$ order Bessel function of the
  2251.  second kind. {\tt besyn()} expects its second argument to be in
  2252.  radians.
  2253.  
  2254. @ifhelp
  2255. ?math cbrt
  2256. ?cbrt
  2257. @else
  2258. \subsection{math function cbrt}
  2259. @endif
  2260.  
  2261.  The {\tt cbrt()} function returns the cubic root of its argument.
  2262.  
  2263. @ifhelp
  2264. ?math ceil
  2265. ?ceil
  2266. @else
  2267. \subsection{math function ceil}
  2268. @endif
  2269.  
  2270.  The {\tt ceil()} function returns the smallest integer that is not
  2271.  less than its argument.
  2272.  
  2273. @ifhelp
  2274. ?math cos
  2275. ?cos
  2276. @else
  2277. \subsection{math function cos}
  2278. @endif
  2279.  
  2280.  The {\tt cos()} function returns the cosine of its argument. {\tt
  2281.  cos()} expects its argument to be in radians.
  2282.  
  2283. @ifhelp
  2284. ?math cosh
  2285. ?cosh
  2286. @else
  2287. \subsection{math function cosh}
  2288. @endif
  2289.  
  2290.  The {\tt cosh()} function returns the hyperbolic cosine of its
  2291.  argument.
  2292.  
  2293. @ifhelp
  2294. ?math cot
  2295. ?cot
  2296. @else
  2297. \subsection{math function cot}
  2298. @endif
  2299.  
  2300.  The {\tt cot()} function returns the cotangent of its argument. {\tt
  2301.  cot()} expects its argument to be in radians.
  2302.  
  2303. @ifhelp
  2304. ?math coth
  2305. ?coth
  2306. @else
  2307. \subsection{math function coth}
  2308. @endif
  2309.  
  2310.  The {\tt coth()} function returns the hyperbolic cotangent of its
  2311.  argument.
  2312.  
  2313. @ifhelp
  2314. ?math csc
  2315. ?csc
  2316. @else
  2317. \subsection{math function csc}
  2318. @endif
  2319.  
  2320.  The {\tt csc()} function returns the cosecant of its argument. {\tt
  2321.  csc()} expects its argument to be in radians.
  2322.  
  2323. @ifhelp
  2324. ?math csch
  2325. ?csch
  2326. @else
  2327. \subsection{math function csch}
  2328. @endif
  2329.  
  2330.  The {\tt csch()} function returns the hyperbolic cosecant of its
  2331.  argument.
  2332.  
  2333. @ifhelp
  2334. ?math erf
  2335. ?erf
  2336. @else
  2337. \subsection{math function erf}
  2338. @endif
  2339.  
  2340.  The {\tt erf()} function returns the error function of its argument.
  2341.  The error function is defined as
  2342. @iftex
  2343.     \[ \frac{2}{\sqrt\pi} \int_0^x e^{-t^2}  dt \]
  2344. @else
  2345.  
  2346.     2/sqrt(pi) * integral from 0 to x of { exp(-t^2) dt }
  2347. @endif
  2348.  
  2349. @ifhelp
  2350. ?math erfc
  2351. ?erfc
  2352. @else
  2353. \subsection{math function erfc}
  2354. @endif
  2355.  
  2356.  The {\tt erfc()} function returns {\tt 1 - erf()} where {\tt erf()} is
  2357.  the error function of its argument. It is provided because of the
  2358.  extreme loss of relative accuracy if {\tt erf(x)} is called for large
  2359.  $x$ and the result subtracted from 1.0 (e.g., for $x = 10$, 12 places
  2360.  are lost).
  2361.  
  2362. @ifhelp
  2363. ?math exp
  2364. ?exp
  2365. @else
  2366. \subsection{math function exp}
  2367. @endif
  2368.  
  2369.  The {\tt exp()} function returns the exponential function of its
  2370.  argument ($e$ raised to the power of its argument). Overflow is
  2371.  checked on all {\tt exp()} operations.
  2372.  
  2373. @ifhelp
  2374. ?math floor
  2375. ?floor
  2376. @else
  2377. \subsection{math function floor}
  2378. @endif
  2379.  
  2380.  The {\tt floor()} function returns the largest integer not greater
  2381.  than its argument.
  2382.  
  2383. @ifhelp
  2384. ?math hypoth
  2385. ?hypot
  2386. @else
  2387. \subsection{math function hypot}
  2388. @endif
  2389.  
  2390.  The {\tt hypot(x, y)} function returns sqrt(x*x+y*y) computed in such
  2391.  a way that underflow will not happen, and overflow occurs only if the
  2392.  final result deserves it.
  2393.  
  2394. @ifhelp
  2395. ?math int
  2396. ?int
  2397. @else
  2398. \subsection{math function int}
  2399. @endif
  2400.  
  2401.  The {\tt int()} function returns the integer part of its argument,
  2402.  truncated toward zero. The returned value is still a double. This
  2403.  function is equivalent to trunc() is is kept for compatibility.
  2404.  
  2405. @ifhelp
  2406. ?math interp
  2407. ?interp
  2408. @else
  2409. \subsection{math function interp}
  2410. @endif
  2411.  
  2412.  The {\tt interp()} function returns an interpolated value of the
  2413.  function at the value of its argument. The functional relation is
  2414.  previously initialized using the fitting mode command {\tt spline}.
  2415.  The interpolation is obtained from cubic splines. {\it Natural} (i.e.,
  2416.  the second derivative of the interpolating function at either or both
  2417.  the first and last point of the original data equal zero) cubic spline
  2418.  or specific first derivatives at the extreme points of the original
  2419.  data set are specified while initializing the process using {\tt spline}
  2420.  command.
  2421.  
  2422. \Seealso
  2423. \bq spline\eq
  2424.  
  2425. @ifhelp
  2426. ?math lgamma
  2427. ?lgamma
  2428. @else
  2429. \subsection{math function lgamma}
  2430. @endif
  2431.  
  2432.  The {\tt lgamma()} function returns the natural logarithm of the gamma
  2433.  function of its argument. For an integer {\tt n, lgamma(n+1) =
  2434.  ln(fac(n))} where fac is a factorial function.
  2435.  
  2436. @ifhelp
  2437. ?math ln
  2438. ?ln
  2439. @else
  2440. \subsection{math function ln}
  2441. @endif
  2442.  
  2443.  The {\tt ln()} function returns the natural logarithm (base $e$ ) of
  2444.  its argument. Illegal argument is checked for.
  2445.  
  2446. @ifhelp
  2447. ?math log
  2448. ?log
  2449. @else
  2450. \subsection{math function log}
  2451. @endif
  2452.  
  2453.  The {\tt log()} function returns the logarithm (base 10) of its
  2454.  argument.
  2455.  
  2456. @ifhelp
  2457. ?math max
  2458. ?max
  2459. @else
  2460. \subsection{math function max}
  2461. @endif
  2462.  
  2463.  The built-in function {\tt max(x, y)} returns the maximum value of
  2464.  x and y. {\tt max(x, max(y, z))} obviously returns the largest value
  2465.  of x, y, and z.
  2466.  
  2467. @ifhelp
  2468. ?math min
  2469. ?min
  2470. @else
  2471. \subsection{math function min}
  2472. @endif
  2473.  
  2474.  The built-in function {\tt min(x, y)} returns the minimum value of
  2475.  x and y. {\tt min(x, min(y, z))} obviously returns the smallest value
  2476.  of x, y, and z.
  2477.  
  2478. @ifhelp
  2479. ?math rand
  2480. ?rand
  2481. @else
  2482. \subsection{math function rand}
  2483. @endif
  2484.  
  2485.  The {\tt rand()} function returns a random number between [0,1).
  2486.  Depending on the machine on which it is compiled, it might use the
  2487.  extended 48 bits random number generator or less.
  2488.  
  2489. @ifhelp
  2490. ?math rint
  2491. ?rint
  2492. @else
  2493. \subsection{math function rint}
  2494. @endif
  2495.  
  2496.  The {\tt rint()} function returns the value of its argument rounded to
  2497.  the nearest integer.
  2498.  
  2499. @ifhelp
  2500. ?math scan
  2501. ?scan
  2502. @else
  2503. \subsection{math function scan}
  2504. @endif
  2505.  
  2506.  This math function is a bit different from others in the fact that it
  2507.  handles strings and returns a number. In fact, the {\tt scan({\it
  2508.  String, Format})} function returns a double precision number as
  2509.  extracted from string {\it String} and according to string format {\it
  2510.  Format}. The format is built with the same rules {\tt sscanf} uses.
  2511.  See man pages on {\tt scanf(3)}. Note that the format must contain
  2512.  one active "\%lf". An example might be of some help here, especially
  2513.  to show how to use {\tt scan} in conjunction with C-calculator mode
  2514.  defined strings. {\tt scan} is particularly helpful to extract numbers
  2515.  from filenames. Recall that strings are defined by double quotes as
  2516.  in standard C.
  2517.  
  2518.  At this point, it might be useful for you to know the "\%[ ]" scanf
  2519.  construction. Let's go through some examples: {\tt "\%*[a-zA-Z]"}
  2520.  means to ignore the longest string matched so that it is composed of
  2521.  any letter; {\tt "\%*[\^{ }0-9]"} means to ignore the longest string
  2522.  matched so that it is NOT composed of any digit; {\tt "\%*[\^{ }\_.]"}
  2523.  means to ignore the longest string matched so that it is not composed
  2524.  of characters `\_' or `.'.
  2525.  
  2526. \Examples
  2527. \nopagebreak\begin{verbatim}
  2528.      # define a string called Testname
  2529.      let Testname = "dummy25.dat"
  2530.      # let y be the Neperian log of the number contained in that string
  2531.      let y = ln(scan(Testname, "%*[^0-9]%lf.dat"))
  2532.      # The following reads a number from stdin
  2533.      let input = scan(Read(), "%lf")
  2534. \end{verbatim}
  2535.  
  2536. \Seealso
  2537. \bq \$, strings, C, cmode, quotes \eq
  2538.  
  2539. @ifhelp
  2540. ?math sec
  2541. ?sec
  2542. @else
  2543. \subsection{math function sec}
  2544. @endif
  2545.  
  2546.  The {\tt sec()} function returns the secant of its argument. {\tt
  2547.  sec()} expects its argument to be in radians.
  2548.  
  2549. @ifhelp
  2550. ?math sech
  2551. ?sech
  2552. @else
  2553. \subsection{math function sech}
  2554. @endif
  2555.  
  2556.  The {\tt sech()} function returns the hyperbolic secant of its
  2557.  argument.
  2558.  
  2559. @ifhelp
  2560. ?math sin
  2561. ?sin
  2562. @else
  2563. \subsection{math function sin}
  2564. @endif
  2565.  
  2566.  The {\tt sin()} function returns the sine of its argument. {\tt
  2567.  sin()} expects its argument to be in radians.
  2568.  
  2569. @ifhelp
  2570. ?math sinh
  2571. ?sinh
  2572. @else
  2573. \subsection{math function sinh}
  2574. @endif
  2575.  
  2576.  The {\tt sinh()} function returns the hyperbolic sine of its
  2577.  argument. {\tt sinh()} expects its argument to be in radians.
  2578.  
  2579. @ifhelp
  2580. ?math sqrt
  2581. ?sqrt
  2582. @else
  2583. \subsection{math function sqrt}
  2584. @endif
  2585.  
  2586.  The {\tt sqrt()} function returns the square root of its argument.
  2587.  
  2588. @ifhelp
  2589. ?math srand
  2590. ?srand
  2591. @else
  2592. \subsection{math function srand}
  2593. @endif
  2594.  
  2595.  The {\tt srand()} function sets the seed of the random number
  2596.  generator. Its argument will always be truncated to an integer
  2597.  towards zero. {\tt srand()} returns the truncated value.
  2598.  
  2599. @ifhelp
  2600. ?math sum
  2601. ?sum
  2602. @else
  2603. \subsection{math function sum}
  2604. @endif
  2605.  
  2606.  The {\tt sum} function returns the sum of the elements of the vector
  2607.  passed as an argument. Recall that vector are passed by pointers so
  2608.  that {\tt y = sum(X$^2$)} is not legal. Instead, on must explicitly
  2609.  calculate
  2610. @ifhelp
  2611.  
  2612. @endif
  2613. \nopagebreak\begin{verbatim}
  2614.  # Given vector X, the following calculates the sum of X^2
  2615.  let X2 = X^2
  2616.  let y = sum(X2)
  2617. \end{verbatim}
  2618. @ifhelp
  2619.  
  2620. @endif
  2621.  in order to evaluate the sum. The {\tt sum} function can be used to
  2622.  calculate basic statistics (mean, standard deviation, correlation, ...)
  2623.  and to do basic integration together with a spline-interp algorithm
  2624.  if the points are distant and the function smooth enough.
  2625.  
  2626. \Seealso
  2627. \bq interp, spline \eq
  2628.  
  2629. @ifhelp
  2630. ?math tan
  2631. ?tan
  2632. @else
  2633. \subsection{math function tan}
  2634. @endif
  2635.  
  2636.  The {\tt tan()} function returns the tangent of its argument. {\tt
  2637.  tan()} expects its argument to be in radians.
  2638.  
  2639. @ifhelp
  2640. ?math tanh
  2641. ?tanh
  2642. @else
  2643. \subsection{math function tanh}
  2644. @endif
  2645.  
  2646.  The {\tt tanh()} function returns the hyperbolic tangent of its
  2647.  argument. {\tt tanh()} expects its argument to be in radians.
  2648.  
  2649. @ifhelp
  2650. ?math trunc
  2651. ?trunc
  2652. @else
  2653. \subsection{math function trunc}
  2654. @endif
  2655.  
  2656.  The {\tt trunc()} function returns the value of the argument when
  2657.  truncated towards zero.
  2658.  
  2659. @ifhelp
  2660. ?pause
  2661. ?wait
  2662. @else
  2663. \section{pause}
  2664. @endif
  2665.  
  2666. The {\tt pause} command displays any text associated with the command
  2667. and then waits a specified amount of time or until a carriage return is
  2668. pressed if the given time value is a negative integer. The {\tt pause}
  2669. command is especially useful in conjunction with {\tt load}ed files.
  2670.  
  2671. \Syntax
  2672. \bq pause {\it value} {\it string\optio}\eq
  2673.  
  2674. \Examples
  2675. \nopagebreak\begin{verbatim}
  2676.      pause -1
  2677.      pause 3
  2678.      pause -1  Hit return to continue
  2679.      pause 10  This fits equation 4 to file $ReadFile.
  2680. \end{verbatim}
  2681.  
  2682. \Seealso
  2683. \bq echo, load \eq
  2684.  
  2685. @ifhelp
  2686. ?plot
  2687. @else
  2688. \section{plot}
  2689. @endif
  2690.  
  2691.  There exists no plot command as such. However two macros are
  2692.  predefined. One is {\tt gnu!plot} to use with \gnuplot\ and {\tt
  2693.  sgi!plot} to use with \sgiplot. As they currently are, only two
  2694.  vectors can be passed to these macros. They serve like examples for
  2695.  building your own macros as well. See {\tt show macros} to see the
  2696.  contents of the predefined macros of your site.
  2697.  
  2698. \Seealso
  2699. \bq set plotting, special, macro, show macros \eq
  2700.  
  2701. @ifhelp
  2702. ?pmode
  2703. @else
  2704. \section{pmode}
  2705. @endif
  2706.  
  2707.  The {\tt pmode} command talks directly to the plotting program chosen
  2708.  with the {\tt set plotting} command. Any command usually typed to the
  2709.  plotting routine is now valid. Furthermore, all the current variables,
  2710.  constants and their string counterparts can be expanded in the
  2711.  plotting mode. The fitting macros and aliases are not recognized in
  2712.  this mode. The command {\tt fmode} permits the user to return from the
  2713.  plotting mode as does \^{ }D when typed interactively. If {\tt pmode}
  2714.  is called with trailing arguments, the remainder of the line will be
  2715.  passed to the plotting program while remaining in fitting mode. It is
  2716.  not an error to call {\tt pmode} from the plotting mode. An warning
  2717.  message will be given though.
  2718.  
  2719.  If the plotting program is defined as a null string ({\tt set plotting ""})
  2720.  then all command lines given in {\tt pmode} will be ignored and
  2721.  warning messages will be given accordingly.
  2722.  
  2723. \Syntax
  2724. \bq pmode {\it command\optio}\eq
  2725.  
  2726. \Examples
  2727. \nopagebreak\begin{verbatim}
  2728.      pmode
  2729.      pmode set nokey
  2730.      pmode plot "fudgfile" with lines
  2731. \end{verbatim}
  2732.  
  2733. \Seealso
  2734. \bq set plotting, set prompt-pm, special \eq
  2735.  
  2736. @ifhelp
  2737. ?print
  2738. @else
  2739. \section{print}
  2740. @endif
  2741.  
  2742.  The {\tt print} command is a C-calculator mode command that writes the
  2743.  value of a valid mathematical expression to a file selected by {\tt
  2744.  set output}. The default is {\it stdout}. If there is more than one
  2745.  variable, a coma separated list must be given in which case each
  2746.  expression value will printed on the same line and separated by a tab.
  2747.  As with other number output commands, the output format is the one
  2748.  selected by the {\tt set format} command. The default is "% 10.8e".
  2749.  The {\tt print} command differs from {\tt show variables} as follows:
  2750.  
  2751.  $\bullet$ {\tt print} accepts any expression for indexing vector elements;
  2752.  
  2753.  $\bullet$ {\tt print} requires a comma separated list;
  2754.  
  2755.  $\bullet$ {\tt print} can be part of a function or procedure;
  2756.  
  2757.  $\bullet$ {\tt print} can print strings provided they are in double
  2758.           quotes. This includes characters '\verb+\n+', '\verb+\t+', '\verb+\a+', \ldots;
  2759.  
  2760.  $\bullet$ {\tt print} does not append a newline.
  2761.  
  2762.  $\bullet$ {\tt print} can print any mathemetical expression.
  2763.  
  2764.  $\bullet$ {\tt print} is a C-calculator mode command.
  2765.  
  2766.  A simpler way to print variables to {\it stdout} from the C-calculator
  2767.  mode is to use the feature that any variable or coma separated list of
  2768.  variables given on the command line will be displayed, separated by tabs
  2769.  and appended with a newline character. Thus the construction @ifhelp
  2770.  
  2771. @endif
  2772. \nopagebreak\begin{verbatim}
  2773.      set output stdout
  2774.      cmode
  2775.          print x, y, "\n"
  2776. \end{verbatim}
  2777. @ifhelp
  2778.  
  2779. @endif
  2780.  is equivalent to
  2781. @ifhelp
  2782.  
  2783. @endif
  2784. \nopagebreak\begin{verbatim}
  2785.      cmode
  2786.          x, y
  2787. \end{verbatim}
  2788. @ifhelp
  2789.  
  2790. @endif
  2791.  typed in C-calculator mode (it becomes {\tt let x,y} in fitting mode).
  2792.  The only difference between {\tt print} and the automatic printing
  2793.  feature of C-calculator mode is that (1) {\tt set output} only affects
  2794.  {\tt print} command, and that (2) {\tt print} does not automatically
  2795.  append a new line character.
  2796.  
  2797. \Syntax
  2798. \bq print {\it coma-separated-var-list} \eq
  2799.  
  2800. \Examples
  2801. \nopagebreak\begin{verbatim}
  2802.      cmode
  2803.          print x+2
  2804.          print String, x, y, z
  2805.          print "Warning \a\a\a", "x = ", x, "\n"
  2806. \end{verbatim}
  2807.  
  2808. \Seealso
  2809. \bq cmode, func, C, show table, show variable, math functions, quotes,\\
  2810.       set format, set output\eq
  2811.  
  2812. @ifhelp
  2813. ?proc
  2814. @else
  2815. \section{proc}
  2816. @endif
  2817.  
  2818.  The {\tt proc} command is a C-calculator command used to define
  2819.  procedures. Procedures differs from functions in the fact that they do
  2820.  not return any value. The procedure arguments are passed and referred
  2821.  to the same way they are in functions. Keyword {\tt proc} is a
  2822.  C-calculator mode command. The {\tt show table} command can be used
  2823.  to list all the installed objects at a given time.
  2824.  
  2825. \Syntax
  2826. \bq proc {\it procedurename}({\it proto-list\optio}) {\it cmode-line-statement} \eq
  2827. @ifhelp
  2828.  
  2829. @endif
  2830.  or
  2831. @ifhelp
  2832.  
  2833. @endif
  2834. \bq proc {\it procedurename}({\it proto-list\optio}) \{\\
  2835.      {\it cmode-statements}\\
  2836. \}\eq
  2837.  
  2838. \Examples
  2839. \nopagebreak\begin{verbatim}
  2840.      # The following example will print the Fibonacci numbers lower than 1000
  2841.      cmode
  2842.          proc fib(x) { 
  2843.              a = 0 
  2844.              b = 1 
  2845.              while (b < x) { 
  2846.                  print b
  2847.                  c = b 
  2848.                  b += a 
  2849.                  a = c 
  2850.              } 
  2851.              print "\n"
  2852.          } 
  2853.          # The following 'for' loop is equivalent to the preceding fib()
  2854.          proc fib2(x) {
  2855.              auto a,b,c        # This proc creates no global variable
  2856.  
  2857.              for(a=0,b=1;b<x;c=b,b+=a,a=c) {
  2858.                  print b
  2859.              }
  2860.              print "\n"
  2861.          }
  2862.          fib(1000)  # A procedure as called from C-calculator mode.
  2863.     fmode
  2864.     let fib2(1000)  # A procedure as called from fitting mode.
  2865.     # A short example involving a vector
  2866.     set data 10
  2867.     let proc init(X, x) X=x
  2868.     let b=3
  2869.     let init(Y, 2/4 + b) # Shows that scalar can also be expressions.
  2870. \end{verbatim}
  2871.  
  2872. \Seealso
  2873. \bq return, cmode, C, func, auto, math, show table, install \eq
  2874.  
  2875. @ifhelp
  2876. ?pwd
  2877. ?cwd
  2878. @else
  2879. \section{pwd}
  2880. @endif
  2881.  
  2882.  The {\tt pwd} command prints the name of the working directory on
  2883.  the screen.
  2884.  
  2885. \Syntax
  2886. \bq pwd\eq
  2887.  
  2888. \Seealso
  2889. \bq cd, ls \eq
  2890.  
  2891. @ifhelp
  2892. ?quit
  2893. @else
  2894. \section{quit}
  2895. @endif
  2896.  
  2897.  The commands {\tt exit} and {\tt quit} are equivalent and both will
  2898.  exit \fudgit. On exit, all temporary files {\it /tmp/fudgitPID*} (note
  2899.  the wild card) will be erased. Here PID is the current process number.
  2900.  Moreover, if a plotting process is active, it will be sent a KILL
  2901.  signal. It is therefore a good habit to use the {\tt \$Tmp} string
  2902.  variable to build your temporary files.
  2903.  
  2904. \Syntax
  2905. \bq quit\eq
  2906.  
  2907. \Seealso
  2908. \bq cmode, exit \eq
  2909.  
  2910. @ifhelp
  2911. ?quotes
  2912. @else
  2913. \section{quotes}
  2914. @endif
  2915.  
  2916.  In the fitting mode, single and double quotes serve to indicate that
  2917.  all the characters between quotes should be taken as only one word,
  2918.  even if there are some blanks (tab or space) among them. The
  2919.  difference between single and double quotes is that within the former
  2920.  variable expansion (using `\$') does not take place whereas it does in
  2921.  the latter. Quotes are not recognized between parentheses.
  2922.  
  2923.  In C-calculator mode, double quotes serve to indicate a string and
  2924.  parsing is done accordingly. As in C, double quotes can be included in
  2925.  a string using the `\verb+\+' operator. Note that C special characters
  2926.  as '\verb+\n+' for a newline, '\verb+\a+' for a bell, '\verb+\t+' for
  2927.  a tab, and so on, are recognized in a string. Single quotes have no
  2928.  special meanings. The only way to pass a `\$' without expanding the
  2929.  following name is to escape the `\$' with a `\verb+\+'.
  2930.  
  2931.  Thus, a null string is given by {\tt ''} or {\tt ""} in the fitting
  2932.  mode and by {\tt ""} only in C-calculator mode.
  2933.  
  2934.  In pmode, both single and double quotes are freely passed to the
  2935.  plotting program. This is valid when trailing commands are are passed
  2936.  to {\tt pmode}, although \fudgit\ implicitly stays in the fitting
  2937.  mode. Once again, expansion of a `\$' followed by a string can be
  2938.  avoided using the escape character, i.e., by typing `\verb+\+\$'.
  2939.  
  2940. \Seealso
  2941. \bq exec, set plotting, math function scan, print \eq
  2942.  
  2943. @ifhelp
  2944. ?read
  2945. @else
  2946. \section{read}
  2947. @endif
  2948.  
  2949.  The {\tt read} command is used to read data points from a file or from
  2950.  standard input. Each column is assigned to a given vector. Vectors not
  2951.  already allocated will automatically be. Range of values can be
  2952.  specified on any variable using the [{\it low}:{\it high}] syntax. A
  2953.  `{\tt *}' replacing a value will be taken as unexistent. Range of
  2954.  lines can be specified on any variable using the \{{\it low}:{\it high}\}
  2955.  syntax. The last line range given will be the only one in effect. If
  2956.  the file name specified is `\dash' data will be read from the current
  2957.  standard input until the keyword {\tt end} is found on a line by
  2958.  itself. The {\tt read} \dash and the {\tt load} commands are recursive
  2959.  functions so they can be nested insofar as you can understand what is
  2960.  going on. An assignment consists in a vector name and a column number
  2961.  separated by a colon. After a file has been successfully read, {\tt
  2962.  read} will put the name of the data file in string constant {\tt
  2963.  ReadFile}.
  2964.  
  2965. \Syntax
  2966. \bq read {\it filename} {\it assignment$[$range$]$\optio\{linerange\}\optio} \ldots\eq
  2967.  
  2968. \Examples
  2969. \nopagebreak\begin{verbatim}
  2970.      read file1 X:1[0:*] Y:2
  2971.      read file2 TIME:2{100:400}
  2972.      read - T:1 VALUE:2
  2973.      1    2.3
  2974.      2    4.7
  2975.      .    .
  2976.      .    .
  2977.      .    .
  2978.      end
  2979. \end{verbatim}
  2980. @ifhelp
  2981.  
  2982. @endif
  2983.  The first form will read positive values of the first column in vector
  2984.  $X$ and corresponding values of the second in vector $Y$. The second
  2985.  will read the second column of file {\it file2} from line 100 to line
  2986.  400. The third will read $T$ and {\it VALUE} from stdin. The
  2987.  assignment does not need to be in increasing order of column. Also
  2988.  note that the first column is 1.
  2989.  
  2990. \Seealso
  2991. \bq exec, data \eq
  2992.  
  2993. @ifhelp
  2994. ?reinstall
  2995. @else
  2996. \section{reinstall}
  2997. @endif
  2998.  
  2999.  The {\tt reinstall} command is used to perform the dynamical loading
  3000.  of a module that was already loaded. Typically, this is done after a
  3001.  module has been modified and recompiled. Refer to {\tt install} for
  3002.  more detail.
  3003.  
  3004. @ifhelp
  3005. ?return
  3006. @else
  3007. \section{return}
  3008. @endif
  3009.  
  3010.  The C-calculator {\tt return} keyword is used as in standard C to
  3011.  return from a function or a procedure. Contrary to C, {\tt return}
  3012.  requires parentheses when returning a value from a function. It is an
  3013.  error to return a value from a procedure or to not return anything
  3014.  from a function. {\tt return} is a C-calculator mode command.
  3015.  
  3016. \Syntax
  3017. \bq return({\it expression})\\
  3018. return \eq
  3019. \Seealso
  3020. \bq C, cmode, func, proc, auto \eq
  3021.  
  3022. @ifhelp
  3023. ?save
  3024. @else
  3025. \section{save}
  3026. @endif
  3027.  
  3028.  Look under {\tt append} command description.
  3029.  
  3030. @ifhelp
  3031. ?set
  3032. @else
  3033. \section{set}
  3034. @endif
  3035.  
  3036.  The {\tt set} command sets a lot of options, as follows.
  3037.  
  3038. @ifhelp
  3039. ?set comment
  3040. @else
  3041. \subsection{set comment}
  3042. @endif
  3043.  
  3044.  The {\tt set comment} command selects the character which will cause
  3045.  the rest of the line to be ignored. The default value is `{\tt \#}'.
  3046.  Note that the effect of a comment character will be void if: (1) found
  3047.  somewhere between single quotes in fitting mode or (2) escaped with a
  3048.  `\verb+\+'.
  3049.  
  3050. \Syntax
  3051. \bq set comment {\it character} \eq
  3052.  
  3053. \Example
  3054. \nopagebreak\begin{verbatim}
  3055.      set comment ?
  3056. \end{verbatim}
  3057.  
  3058. \Seealso
  3059. \bq show comment, comments \eq
  3060.  
  3061. @ifhelp
  3062. ?set data
  3063. ?data
  3064. @else
  3065. \subsection{set data}
  3066. @endif
  3067.  
  3068.  The {\tt set data} command changes the effective size of vectors. All
  3069.  the vector arithmetic checks for index boundaries. The {\tt data}
  3070.  constant is the higher bound of the check and necessarily the size of
  3071.  all vectors. Changing the {\tt data} value does not change the values
  3072.  nor the capacity of vectors. It only changes the upper bound on the
  3073.  value the index can take. The {\tt data} constant is also changed by
  3074.  the commands {\tt read} and {\tt exec}, which set it to the number of
  3075.  valid data points read. Because the upper bound can never be higher
  3076.  than the effective capacity of vectors, a {\tt data} value higher than
  3077.  the current {\tt samples} value will be refused. See {\tt set
  3078.  samples}. Typically, {\tt set data} is used when one wants the
  3079.  C-calculator to generate (and plot) vectors. The {\tt read} and {\tt
  3080.  exec} commands take care of adjusting it. {\tt data} constant can also
  3081.  be changed from the C-calculator mode if the constant is {\tt
  3082.  unlock}ed. However, no check is made to ensure the given value is not
  3083.  higher than {\tt sample} size, in which case a segmentation fault will
  3084.  crash the whole program. It is always safer to use {\tt set data}.
  3085.  
  3086. \Syntax
  3087. \bq set data {\it number}\eq
  3088.  
  3089. \Example
  3090. \nopagebreak\begin{verbatim}
  3091.      set data 300
  3092. \end{verbatim}
  3093.  
  3094. \Seealso
  3095. \bq lock, unlock, read, exec, cmode\eq 
  3096.  
  3097. @ifhelp
  3098. ?set debug
  3099. ?debug
  3100. @else
  3101. \subsection{set debug}
  3102. @endif
  3103.  
  3104.  The {\tt set debug} command puts the reading of {\tt load}ed files in
  3105.  verbose mode, so that debugging is more easily done. All the commands,
  3106.  expanded macros and/or string variables are echoed as they are
  3107.  executed. There are some different debug levels at the present time:
  3108.  
  3109.  $\bullet$ 0 clear all the debugging states.
  3110.  
  3111.  $\bullet$ 1 echo the expanded lines as they are read. The command is
  3112.           parsed and comments are stripped out. This is most useful
  3113.           for debugging script files. History substitutions are shown.
  3114.  
  3115.  $\bullet$ 2 display all command lines as they are read from the script.
  3116.  
  3117.  $\bullet$ 3 display the line numbers of the ignored lines as they are
  3118.           read from datafiles.
  3119.  
  3120.  $\bullet$ 4 echo command lines as they are passed to the math parser.
  3121.  
  3122.  $\bullet$ 5 turn the math parser debugger on. To use this, the program
  3123.           must have been compiled with the YYDEBUG preprocessor
  3124.           variable on.
  3125.  
  3126.  $\bullet$ 6 trace the flow of fitting mode {\tt if} constructions.
  3127.  
  3128.  Debugging values are not exclusive so that more than one level
  3129.  can be turned on. Levels are subject to change.
  3130.  
  3131. \Syntax
  3132. \bq set debug {\it value-list} \eq
  3133.  
  3134. \Example
  3135. \bq set debug 0 1 3\eq
  3136.  
  3137. \Seealso
  3138. \bq load \eq
  3139.  
  3140. @ifhelp
  3141. ?set error
  3142. ?error
  3143. @else
  3144. \subsection{set error}
  3145. @endif
  3146.  
  3147.  \fudgit\ allows the user to select among different possible error
  3148.  checks to be made on each single mathematical operations. The
  3149.  {\tt set error} command will set computational error checks as follows:
  3150.  
  3151.  $\bullet$ 0: clear all computational error check bits.
  3152.  
  3153.  $\bullet$ 1: check for `infinity' values.
  3154.  
  3155.  $\bullet$ 2: check for `not a number' values.
  3156.  
  3157.  $\bullet$ 3: check for `out of domain' math function errors.
  3158.  
  3159.  $\bullet$ 4: check for `out of range' math function errors.
  3160.  
  3161.  Error checks are not exclusive and more than one can be specified on
  3162.  the command line. The default status has all error check levels
  3163.  activated (1 2 3 4).
  3164.  
  3165.  It is sometimes desirable to disable one of the checks. For example,
  3166.  the operation $y = 1/sinh(x)$ will give a `out of range' error for
  3167.  large $x$ ( $> 709$ on most machines), although $y$ is in fact 0.
  3168.  If one uses {\tt set error 0 1 2 3}, then no error will be reported
  3169.  and $y$ will be set to zero accordingly.
  3170.  
  3171. \Syntax
  3172. \bq set debug {\it value-list} \eq
  3173.  
  3174. \Example
  3175. \bq set error 0 2 3\eq
  3176.  
  3177. \Seealso
  3178. \bq C, cmode \eq
  3179.  
  3180. @ifhelp
  3181. ?set expand
  3182. ?expand
  3183. @else
  3184. \subsection{set expand}
  3185. @endif
  3186.  
  3187.  In interactive mode, history expansion and substitution will occur
  3188.  only if the {\tt expand} variable is set. It is disabled using {\tt
  3189.  set noexpand}. The default is on.
  3190.  
  3191. \Syntax
  3192. \bq set expand \eq
  3193.  
  3194. \Seealso
  3195. \bq set noexpand, history, line editing \eq
  3196.  
  3197. @ifhelp
  3198. ?set format
  3199. ?format
  3200. @else
  3201. \subsection{set format}
  3202. @endif
  3203.  
  3204.  The command {\tt set format} will set the printf format for variables.
  3205.  Use only if you are sure of what you are doing. It defaults to
  3206.  ``\% 10.8e". See {\tt man printf(3)} if in doubt.
  3207.  
  3208. \Syntax
  3209. \bq set format {\it string}\eq
  3210.  
  3211. \Examples
  3212. \nopagebreak\begin{verbatim}
  3213.       set format %6.2lf
  3214.       set format "% .8g"
  3215. \end{verbatim}
  3216.  
  3217. \Seealso
  3218. \bq show, append \eq
  3219.  
  3220. @ifhelp
  3221. ?set function
  3222. ?function
  3223. @else
  3224. \subsection{set function}
  3225. @endif
  3226.  
  3227.  The {\tt set function} command is perhaps the most crucial command in
  3228.  data fitting. It is used to select a built-in fitting function or to
  3229.  enter a user-defined function. The following fitting functions are
  3230.  available:
  3231. @ifhelp
  3232.  
  3233. @endif
  3234. \nopagebreak\begin{verbatim}
  3235.      NAME          DESCRIPTION             PARAMETERS REQUIRED
  3236.      ----          -----------             -------------------
  3237.      straight      Straight line           (2 parameters)
  3238.      sine          Sine series             (N parameters)
  3239.      cosine        Cosine series           (N parameters)
  3240.      legendre      Legendre series         (N parameters)
  3241.      polynomial    Power series            (N parameters)
  3242.      gauss         Gaussian series         (3N parameters)
  3243.      expo          Exponential series      (2N parameters)
  3244.      user          User-defined function   (N parameters)
  3245. \end{verbatim}
  3246.  
  3247.  Assume a variable vector $X$ and a parameter vector $A$ then,
  3248.  the nonlinear gauss fitting function is a series of gaussians where
  3249. @iftex
  3250. \[ f(X,A) = \sum_{i=1,4,7, \ldots, N} A[i] \times e^{- \left(
  3251. \frac{(X - A[i+1])}{A[i+2]}\right)^ 2}. \]
  3252. @else
  3253.  
  3254.     f(X,A) = SUM (i=1,4,7,...,N) of A[i] * exp(-((X - A[i+1])/A[i+2])^ 2).
  3255.  
  3256. @endif
  3257.  
  3258.  The nonlinear expo function is a series of exponentials where
  3259. @iftex
  3260.  \[ f(X,A) = \sum_{1=1,3,\ldots, N} A[i] \times e^{X*A[i+1]} .\]
  3261. @else
  3262.  
  3263.     f(X,A) = SUM (1=1,3,...,N) of A[i] * exp(X*A[i+1]).
  3264.  
  3265. @endif
  3266.  
  3267.  For a user-defined function, the {\tt set function user} will prompt
  3268.  for more input. The following input is related to the variable to
  3269.  fit. For purposes of clarity, let's say that we have to fit vectors
  3270.  {\tt X Y DY}. This requires a fit function {\tt YFIT} (the name is
  3271.  made from the dependent variable appended with {\tt FIT}) and all the
  3272.  partial derivatives {\tt DYFITD1, DYFITD2, \ldots, DYFITDN} taken with
  3273.  respect to the parameters $n=1,\ldots N$. All these functions are
  3274.  defined one per line as in the case of a macro until a {\tt stop} is
  3275.  entered. Temporary variables are permitted. {\tt set function user}
  3276.  actually defines a C-calculator mode macro that will be executed
  3277.  before each iteration of the fit. Therefore the complete C-calculator
  3278.  mode grammar is fully supported here. Temporary vectors can thus be
  3279.  used to speed up the calculation.
  3280.  
  3281.  The C-calculator macro can be a simple call to a predefined procedure.
  3282.  When defined so, the parsing does not have to be done at each iteration,
  3283.  and a slightly faster process should result.
  3284.  
  3285. \Example
  3286. \nopagebreak\begin{verbatim}
  3287.     # read column 1, 2 and 3 of file "file"
  3288.     read file T:1 R:2 DR:3
  3289.     # make a three parameter fit
  3290.     set parameter K 3
  3291.     # this is a linear fit; use singular value decomposition
  3292.     set method svd_fit
  3293.     # enter my function
  3294.     set function user
  3295.         RFIT = K[1] + K[2]*T^0.5 + K[3]*T^1.5
  3296.         DRFITD1 = 1
  3297.         DRFITD2 = T^0.5
  3298.         DRFITD3 = T^1.5
  3299.     stop
  3300.     fit T R DR
  3301. \end{verbatim}
  3302.  
  3303.  The vector {\tt RFIT} will contain the fitted function. The difference
  3304.  between the fit and real data can be obtained right away by defining a
  3305.  vector
  3306. @ifhelp
  3307.  
  3308. @endif
  3309. \nopagebreak\begin{verbatim}
  3310.    let RDIFF = R - RFIT
  3311. \end{verbatim}
  3312. @ifhelp
  3313.  
  3314. @endif
  3315. that can be plotted with respect to {\tt T}.
  3316.  
  3317.  The same thing is done for nonlinear fit with the exception that the
  3318.  partial derivatives of the function with respect to the parameters
  3319.  will contain reference to some parameter(s). (This is precisely the
  3320.  meaning of nonlinear here).
  3321.  
  3322.  There is virtually no restriction on the number of parameters (memory
  3323.  is the sole limitation: {\tt set parameter} command allocates a
  3324.  matrix of {\tt parameters} X {\tt samples} ). The only conditions are
  3325.  that a linear regression must have 2 parameters defined (this is
  3326.  obvious) and the built-in nonlinear functions must be modulo 3 for the
  3327.  series of gaussians and modulo 2 for the series of exponentials.
  3328.  
  3329. \Seealso
  3330. \bq fit, set method, adjust, proc, auto \eq
  3331.  
  3332. @ifhelp
  3333. ?set input
  3334. ?input
  3335. @else
  3336. \subsection{set input}
  3337. @endif
  3338.  
  3339.  The {\tt set input} command selects the file for the input of the
  3340.  C-calculator mode {\tt Read} and {\tt vread} command. The string {\it
  3341.  stdin} is valid as a filename. If the selected file does not exist or
  3342.  cannot be read, an error message will be given and the value will go
  3343.  back to the default value, which is {\it stdin}.
  3344.  
  3345. \Syntax
  3346. \bq set input {\it filename} \eq
  3347.  
  3348. \Seealso
  3349. \bq Read, vread \eq
  3350.  
  3351. @ifhelp
  3352. ?set iteration
  3353. ?iteration
  3354. @else
  3355. \subsection{set iteration}
  3356. @endif
  3357.  
  3358.  The {\tt set iteration} command permits the user to change the
  3359.  iteration number for the Marquardt-Levenberg nonlinear fitting method.
  3360.  See {\tt set function}. The default value is 10. However, the fitting
  3361.  process will stop if there is no difference in $\chi^2$ for two
  3362.  consecutive iterations. However, a negative value will force to
  3363.  iterate up to the absolute value of that number, without checking for
  3364.  convergence.
  3365.  
  3366. \Syntax
  3367. \bq set iteration {\it value}\eq
  3368.  
  3369. \Example
  3370. \bq set iteration 3\eq
  3371.  
  3372. \Seealso
  3373. \bq fit, set method, set function \eq
  3374.  
  3375. @ifhelp
  3376. ?set method
  3377. ?method
  3378. @else
  3379. \subsection{set method}
  3380. @endif
  3381.  
  3382.  The {\tt set method} command allows the user to select the fitting
  3383.  method to be used when calling the {\tt fit} command. The following
  3384.  methods are available:
  3385. @ifhelp
  3386.  
  3387. @endif
  3388. \nopagebreak\begin{verbatim}
  3389.      NAME         DESCRIPTION
  3390.      ----         -----------
  3391.      ls_reg       least square linear regression (2 parameters)
  3392.      lad_reg      least absolute deviation linear regression (2 parameters)
  3393.      ls_fit       general least square linear fit using QR decomposition
  3394.      svd_fit      general least square linear fit using singular value
  3395.                    decomposition
  3396.      ml_fit       general least square nonlinear fit using
  3397.                    Marquardt-Levenberg method
  3398. \end{verbatim}
  3399.  
  3400.  Among them, only {\tt ml\_fit} and {ls\_fit} depends on {\tt iteration}
  3401.  and {\tt adjust}.
  3402.  
  3403.  For all methods except {\tt lad\_reg}, the value of $\chi^2$ will be put
  3404.  in the scalar constant {\tt chi2}. In the case of {\tt lad\_reg}, %\chi^2$
  3405.  will contain the average absolute deviation.
  3406.  
  3407. \Syntax
  3408. \bq set method {\it method}\eq
  3409.  
  3410. \Example
  3411. \bq set method svd\eq
  3412.  
  3413. \Seealso
  3414. \bq fit, set iteration, set function \eq
  3415.  
  3416. @ifhelp
  3417. ?set noexpand
  3418. ?noexpand
  3419. @else
  3420. \subsection{set noexpand}
  3421. @endif
  3422.  
  3423.  The {\tt set noexpand} command disallows history expansion on the
  3424.  interactive command line.
  3425.  
  3426. \Syntax
  3427. \bq set noexpand \eq
  3428.  
  3429. \Seealso
  3430. \bq set expand \eq
  3431.  
  3432. @ifhelp
  3433. ?set output
  3434. ?output
  3435. @else
  3436. \subsection{set output}
  3437. @endif
  3438.  
  3439.  The {\tt set output} command selects the file for the output of the
  3440.  C-calculator mode {\tt print} command. The strings {\it stdout} and
  3441.  {\it stderr} are both valid as a filename. If the selected file
  3442.  already exists, it will be overwritten with no warning. The default
  3443.  value is {\it stdout}.
  3444.  
  3445. \Syntax
  3446. \bq set output {\it filename} \eq
  3447.  
  3448. \Seealso
  3449. \bq print \eq
  3450.  
  3451. @ifhelp
  3452. ?set pager
  3453. ?pager
  3454. @else
  3455. \subsection{set pager}
  3456. @endif
  3457.  
  3458.  The {\tt set pager} command allows the user to select a pager. A pager
  3459.  is the program that is called when the structure to be displayed has
  3460.  more than 24 elements. The default pager is (1) the environment
  3461.  variable PAGER if it exists or (2) {\it /usr/?/more} (path depends on
  3462.  system) if not. If {\tt pager} is defined to a null string ({\tt ""}),
  3463.  then no pager will be used.
  3464.  
  3465. \Syntax
  3466. \bq set pager {\it string}\eq
  3467.  
  3468. \Example
  3469. \bq set pager "more -c"\eq
  3470.  
  3471. \Seealso
  3472. \bq show, show pager \eq
  3473.  
  3474. @ifhelp
  3475. ?set parameters
  3476. ?parameters
  3477. @else
  3478. \subsection{set parameters}
  3479. @endif
  3480.  
  3481.  The command {\tt set parameters} will fix the parameter name and
  3482.  size. Since the set of parameters is a kind of vector, parameter name
  3483.  cannot contain lower case letters. Parameters are initialized to
  3484.  zero. A built-in scalar constant called {\tt param} contains the
  3485.  number of parameters at all time.
  3486.  
  3487. \Syntax
  3488. \bq set parameters {\it parameter-name} {\it size}\eq
  3489.  
  3490. \Example
  3491. \nopagebreak\begin{verbatim}
  3492.      # set the vector D of size 3 to be determined by the fit.
  3493.      set parameters D 3
  3494. \end{verbatim}
  3495.  
  3496. \Seealso
  3497. \bq show parameters, show setup\eq
  3498.  
  3499. @ifhelp
  3500. ?set plotting
  3501. ?plotting
  3502. @else
  3503. \subsection{set plotting}
  3504. @endif
  3505.  
  3506.  The {\tt set plotting} command changes the default plotting program
  3507.  used by the plotting mode. The default is \gnuplot\ but this can be
  3508.  changed to any plotting program that can be driven from stdin. A
  3509.  maximum of 16 arguments can be passed when the program is first
  3510.  called. Changing the plotting program will send a KILL signal to the
  3511.  existing plotting program (if any). If the plotting program is set to
  3512.  a null string ({\tt ""}), \fudgit\ will ignore all the plotting
  3513.  commands and warning messages will be given. Setting the plotting
  3514.  program to a file that cannot be found or executed will result in an
  3515.  error at the first {\tt pmode} call.
  3516.  
  3517. \Syntax
  3518. \bq set plotting {\it command}\eq
  3519.  
  3520. \Examples
  3521. \nopagebreak\begin{verbatim}
  3522.      set plotting "/usr/local/bin/sgiplot -p"
  3523.      set plotting /usr/local/bin/gnuplot
  3524. \end{verbatim}
  3525.  
  3526. \Seealso
  3527. \bq show plotting \eq
  3528.  
  3529. @ifhelp
  3530. ?set prompts
  3531. ?prompts
  3532. @else
  3533. \subsection{set prompts}
  3534. @endif
  3535.  
  3536.  All three \fudgit\ prompts can be changed by the {\tt set} command.
  3537.  The name of the prompts are:
  3538.  
  3539.  $\bullet$ {\tt prompt-cm} for the C-calculator mode prompt
  3540.           (default: "cmode$>$ ";
  3541.  
  3542.  $\bullet$ {\tt prompt-fm} for the fitting mode prompt
  3543.           (default: "fudgit$>$ ";
  3544.  
  3545.  $\bullet$ {\tt prompt-pm} for the plotting mode prompt
  3546.           (default: "pmode$>$ ".
  3547.  
  3548.  A null string {\tt ""} (i.e., two consecutive quotes) can be given to
  3549.  any of these.
  3550.  
  3551. \Syntax
  3552. \bq set prompt-cm {\it string}\\
  3553. set prompt-fm {\it string}\\
  3554. set prompt-pm {\it string}\eq
  3555.  
  3556. \Seealso
  3557. \bq show prompts \eq
  3558.  
  3559. @ifhelp
  3560. ?set samples
  3561. ?samples
  3562. @else
  3563. \subsection{set samples}
  3564. @endif
  3565.  
  3566.  The command {\tt set samples} changes the current capacity of the
  3567.  fitting program. Typically, {\tt samples} is set at the beginning of a
  3568.  session since all the existing vectors and variables are erased on
  3569.  this call. The default setting is 4000 points.
  3570.  
  3571. \Syntax
  3572. \bq set samples {\it value}\eq
  3573.  
  3574. \Example
  3575. \bq set samples 6000\eq
  3576.  
  3577. \Seealso
  3578. \bq set data, cmode, let, lock \eq
  3579.  
  3580. @ifhelp
  3581. ?set vformat
  3582. ?vformat
  3583. @else
  3584. \subsection{set vformat}
  3585. @endif
  3586.  
  3587.  The command {\tt set vformat} will set the sprintf format used for the
  3588.  expansion of scalar variables by the expansion operator `\$'. Use
  3589.  only if you are sure of what you are doing. It defaults to ``\%.3lg''.
  3590.  See {\tt man printf(3)} if in doubt.
  3591.  
  3592. \Syntax
  3593. \bq set vformat {\it string}\eq
  3594.  
  3595. \Examples
  3596. \nopagebreak\begin{verbatim}
  3597.      set vformat %6.2lf
  3598.      set vformat "%.4lg"
  3599. \end{verbatim}
  3600.  
  3601. \Seealso
  3602. \bq \$, cmode, C \eq
  3603.  
  3604. @ifhelp
  3605. ?shell
  3606. @else
  3607. \section{shell}
  3608. @endif
  3609.  
  3610.  The {\tt shell} command starts a shell according to your SHELL
  3611.  environment variable. It is equivalent to {\tt system} command. Refer
  3612.  to the latter for details.
  3613.  
  3614. @ifhelp
  3615. ?show
  3616. @else
  3617. \section{show}
  3618. @endif
  3619.  
  3620.  The {\tt show} command is used to see the chosen options or to look at
  3621.  any defined vectors, parameters or variables.
  3622.  
  3623. \Seealso
  3624. \bq set, echo \eq
  3625.  
  3626. @ifhelp
  3627. ?show comment
  3628. @else
  3629. \subsection{show comment}
  3630. @endif
  3631.  
  3632.  The {\tt show comment} command echoes the current comment escape
  3633.  character.
  3634.  
  3635. \Syntax
  3636. \bq show comment \eq
  3637.  
  3638. \Seealso
  3639. \bq set comment, comments \eq
  3640.  
  3641. @ifhelp
  3642. ?show data
  3643. @else
  3644. \subsection{show data}
  3645. @endif
  3646.  
  3647.  The {\tt show data} command displays the current value of {\tt data}
  3648.  constant. Left for compatibility.
  3649.  
  3650. \Syntax
  3651. \bq show data \eq
  3652.  
  3653. \Seealso
  3654. \bq set data, lock, unlock, set samples \eq
  3655.  
  3656. @ifhelp
  3657. ?show debug
  3658. @else
  3659. \subsection{show debug}
  3660. @endif
  3661.  
  3662.  The {\tt show debug} command displays the current value of the {\tt
  3663.  debug} variable. The value is displayed in octal since the
  3664.  {\tt set debug} $n$ command turns on the $n^{th}$ bit of this number.
  3665.  
  3666. \Syntax
  3667. \bq show debug \eq
  3668.  
  3669. \Seealso
  3670. \bq set debug \eq
  3671.  
  3672. @ifhelp
  3673. ?show error
  3674. @else
  3675. \subsection{show error}
  3676. @endif
  3677.  
  3678.  The {\tt show error} command displays the current value of the {\tt
  3679.  error} computational check variable. The value is displayed in octal
  3680.  since the {\tt set error} $n$ command turns on the $n^{th}$ bit of
  3681.  this number.
  3682.  
  3683. \Syntax
  3684. \bq show error \eq
  3685.  
  3686. \Seealso
  3687. \bq set error \eq
  3688.  
  3689. @ifhelp
  3690. ?show input
  3691. @else
  3692. \subsection{show input}
  3693. @endif
  3694.  
  3695.  The {\tt show input} command shows the filename selected for the
  3696.  input of the C-calculator mode {\tt Read} and {\tt vread} command.
  3697.  The default value is {\it stdin}
  3698.  
  3699. \Syntax
  3700. \bq show input \eq
  3701.  
  3702. \Seealso
  3703. \bq set input, Read, vread \eq
  3704.  
  3705. @ifhelp
  3706. ?show iterations
  3707. @else
  3708. \subsection{show iteration}
  3709. @endif
  3710.  
  3711.  The {\tt show iteration} command displays the current value of
  3712.  {\tt iteration} variable.
  3713.  
  3714. \Syntax
  3715. \bq show iteration \eq
  3716.  
  3717. \Seealso
  3718. \bq set iteration, set method \eq
  3719.  
  3720. @ifhelp
  3721. ?show fit
  3722. @else
  3723. \subsection{show fit}
  3724. @endif
  3725.  
  3726.  The {\tt show fit} command displays the different quantities relevant
  3727.  to the current fitting method. Typical examples are $\chi^2$, the 
  3728.  covariance matrix, the curvature matrix, correlation factor, etc\ldots
  3729.  
  3730. \Syntax
  3731. \bq show fit\eq
  3732.  
  3733. \Seealso
  3734. \bq fit, set parameters, set function, set method \eq
  3735.  
  3736. @ifhelp
  3737. ?show format
  3738. @else
  3739. \subsection{show format}
  3740. @endif
  3741.  
  3742.  The {\tt show format} command displays the current value of
  3743.  {\tt format} variable. The {\tt format} string is used when
  3744.  displaying any number on the screen. Refer to printf(3) of
  3745.  the \unix\ manual.
  3746.  
  3747. \Syntax
  3748. \bq show format \eq
  3749.  
  3750. \Seealso
  3751. \bq set format, show \eq
  3752.  
  3753. @ifhelp
  3754. ?show function
  3755. @else
  3756. \subsection{show function}
  3757. @endif
  3758.  
  3759.  The command {\tt show function} displays the current function type. If
  3760.  the function type is {\tt user}, then the user-defined function will
  3761.  be displayed.
  3762.  
  3763. \Syntax
  3764. \bq show function\eq
  3765.  
  3766. \Seealso
  3767. \bq set function, show setup, fit, math \eq
  3768.  
  3769. @ifhelp
  3770. ?show macros
  3771. @else
  3772. \subsection{show macros}
  3773. @endif
  3774.  
  3775.  If called with an argument, the {\tt show macros} command will display
  3776.  the specified macro. Otherwise, all currently defined macros will be
  3777.  displayed. The selected {\tt pager} is called if the command is given
  3778.  in interactive mode (at the command line prompt).
  3779.  
  3780. \Syntax
  3781. \bq show macros {\it macroname}\optio\eq
  3782.  
  3783. \Seealso
  3784. \bq set pager, save macros, alias \eq
  3785.  
  3786. @ifhelp
  3787. ?show memory
  3788. ?memory
  3789. @else
  3790. \subsection{show memory}
  3791. @endif
  3792.  
  3793.  The {\tt show memory} function will display the current state of
  3794.  memory consumption of the program. All sizes are given in bytes. It
  3795.  uses a direct call to mallinfo(3). The arena is the size of memory
  3796.  requested by the process to the kernel. It is then split in different
  3797.  blocks shared among the internal matrices and user's vectors, macros,
  3798.  functions, procedures, variables and history.
  3799.  
  3800. \Syntax
  3801. \bq show memory\eq
  3802.  
  3803. \Seealso
  3804. \bq free, show table \eq
  3805.  
  3806. @ifhelp
  3807. ?show method
  3808. @else
  3809. \subsection{show method}
  3810. @endif
  3811.  
  3812.  The {\tt show method} command displays the current value of the
  3813.  fitting {\tt method}. It contains {\it none} by default.
  3814.  
  3815. \Syntax
  3816. \bq show method \eq
  3817.  
  3818. \Seealso
  3819. \bq set method, fit, set function \eq
  3820.  
  3821. @ifhelp
  3822. ?show output
  3823. @else
  3824. \subsection{show output}
  3825. @endif
  3826.  
  3827.  The {\tt show output} command shows the filename selected
  3828.  for the output of the C-calculator mode {\tt print} command. 
  3829.  The default value is {\it stdout}
  3830.  
  3831. \Syntax
  3832. \bq show output \eq
  3833.  
  3834. \Seealso
  3835. \bq set output, print \eq
  3836.  
  3837. @ifhelp
  3838. ?show pager
  3839. @else
  3840. \subsection{show pager}
  3841. @endif
  3842.  
  3843.  The {\tt show pager} command displays the current value of the
  3844.  {\tt pager} program. 
  3845.  
  3846. \Syntax
  3847. \bq show pager \eq
  3848.  
  3849. \Seealso
  3850. \bq set pager, environment, show\eq
  3851.  
  3852. @ifhelp
  3853. ?show parameters
  3854. @else
  3855. \subsection{show parameters}
  3856. @endif
  3857.  
  3858.  The command {\tt show parameters} will display the parameter values on
  3859.  the screen. If the number of parameters is larger than 24, then the
  3860.  selected {\tt pager} will be called if the command is given in
  3861.  interactive mode (at the command line prompt). As with {\tt append}
  3862.  and {\tt save parameters}, {\tt show parameter} can accept optional
  3863.  variable or constant (either string or scalar) list of names, in which
  3864.  case the value of the given variables will be displayed along with the
  3865.  parameter values.
  3866.  
  3867. \Syntax
  3868. \bq show parameters {\it variable-list\optio}\eq
  3869.  
  3870. \Seealso
  3871. \bq set pager, set parameters, save parameters, show fit \eq
  3872.  
  3873. @ifhelp
  3874. ?show plotting
  3875. @else
  3876. \subsection{show plotting}
  3877. @endif
  3878.  
  3879.  The {\tt show plotting} command displays the current value of the
  3880.  {\tt plotting} program. 
  3881.  
  3882. \Syntax
  3883. \bq show plotting \eq
  3884.  
  3885. \Seealso
  3886. \bq set plotting, startup, pmode\eq
  3887.  
  3888. @ifhelp
  3889. ?show prompts
  3890. @else
  3891. \subsection{show prompts}
  3892. @endif
  3893.  
  3894.  The {\tt show prompts} command displays the current values of the
  3895.  different mode {\tt prompts}. 
  3896.  
  3897. \Syntax
  3898. \bq show prompt-cm\\
  3899. show prompt-fm\\
  3900. show prompt-pm\eq
  3901.  
  3902. \Seealso
  3903. \bq set prompt, startup\eq
  3904.  
  3905. @ifhelp
  3906. ?show samples
  3907. @else
  3908. \subsection{show samples}
  3909. @endif
  3910.  
  3911.  The {\tt show samples} command displays the current value of the {\tt
  3912.  samples} variable. Recall that although {\tt data} is responsible for
  3913.  the visible part of all vectors, vectors all have a fixed allocated
  3914.  length of {\tt samples} long. Any change to {\tt samples} through {\tt
  3915.  set samples} frees all the existing vectors.
  3916.  
  3917. \Syntax
  3918. \bq show samples \eq
  3919.  
  3920. \Seealso
  3921. \bq set samples, set data, cmode\eq
  3922.  
  3923. @ifhelp
  3924. ?show setup
  3925. ?setup
  3926. @else
  3927. \subsection{show setup}
  3928. @endif
  3929.  
  3930.  The command {\tt show setup} will show some values of the program,
  3931.  such as the last data filename read, the number of data points, 
  3932.  current capacity, current comment character, current iteration number,
  3933.  current plotting program, etc. Left for compatibility.
  3934.  
  3935. \Syntax
  3936. \bq show setup\eq
  3937.  
  3938. \Seealso
  3939. \bq set comments\eq
  3940.  
  3941. @ifhelp
  3942. ?show table
  3943. ?table
  3944. @else
  3945. \subsection{show table}
  3946. @endif
  3947.  
  3948.  The command {\tt show table} displays the current lookup table of the
  3949.  C-calculator mode parser. It shows all current variables, numbers,
  3950.  vectors and functions included in the internal table. It also shows
  3951.  the state of the internal machine (C interpreter), stack and frame
  3952.  used in the C-calculator. This is used mainly for debugging or to
  3953.  prevent stack or machine code overflow.
  3954.  
  3955. \Syntax
  3956. \bq show table\eq
  3957.  
  3958. \Seealso
  3959. \bq free, show memory, cmode \eq
  3960.  
  3961. @ifhelp
  3962. ?show variables
  3963. @else
  3964. \subsection{show variables}
  3965. @endif
  3966.  
  3967.  Any constants or variables can be displayed on the screen. 
  3968.  The {\tt show variable} command differs from {\tt print} as follows:
  3969.  
  3970.  $\bullet$ {\tt show variables} only accepts integers for indexing
  3971.           vector elements;
  3972.  
  3973.  $\bullet$ {\tt show variables} requires a blank separated list;
  3974.  
  3975.  $\bullet$ {\tt show variables} cannot be part of a function or procedure.
  3976.  
  3977.  As it has been mentioned previously, this is due to the different
  3978.  types of parsing between the C-calculator and fitting modes. As with
  3979.  all other number displaying commands, the printing format is
  3980.  always the one selected by the {\tt set format} command.
  3981.  
  3982. \Syntax
  3983. \bq show variables {\it variable-list} \eq
  3984.  
  3985. \Example
  3986. \bq show variables x X[2] Y[2] DY[2] time\eq
  3987.  
  3988. \Seealso
  3989. \bq print, save variables, show table, show vectors, cmode \eq
  3990.  
  3991. @ifhelp
  3992. ?show vectors
  3993. @else
  3994. \subsection{show vectors}
  3995. @endif
  3996.  
  3997.  Any vector or number of vectors can be seen on the screen. If the size
  3998.  of vectors is larger than 24, the selected {\tt pager} will be called
  3999.  if the command is given in interactive mode (at the command line
  4000.  prompt).
  4001.  
  4002. \Syntax
  4003. \bq show vectors {\it VECTOR-list} \eq
  4004.  
  4005. \Example
  4006. \bq show vectors X Y DY\eq
  4007.  
  4008. \Seealso
  4009. \bq set pager, append vectors, read, cmode, let \eq
  4010.  
  4011. @ifhelp
  4012. ?show vformat
  4013. ?vformat
  4014. @else
  4015. \subsection{show vformat}
  4016. @endif
  4017.  
  4018.  The command {\tt show vformat} will display the printf format used
  4019.  for the expansion of scalar variables by the expansion operator `\$'.
  4020.  Refer to the printf(3) description in the \unix\ manual for more details.
  4021.  
  4022. \Syntax
  4023. \bq show vformat\eq
  4024.  
  4025. \Seealso
  4026. \bq \$, cmode, C, set vformat \eq
  4027.  
  4028. @ifhelp
  4029. ?smooth
  4030. @else
  4031. \section{smooth}
  4032. @endif
  4033.  
  4034.  The {\tt smooth} command uses a gaussian windowing function (low-pass
  4035.  filter) on a Fourier transform loop in order to smooth the given
  4036.  vector. The windowing function is $\exp(-(f/(\sigma \times f_{max}))^2)$
  4037.  where $f_{max}$ is equal to half of the smallest power of 2 larger
  4038.  than the number of data points {\tt data}. Variable $f$ is the
  4039.  frequency that ranges from 0 to $f_{max}$. More likely, the smoothing
  4040.  factor is a non null positive real number from the (0, 1] interval. A
  4041.  smoothing factor $\sigma >= 1$ leaves the vector unchanged.
  4042.  
  4043.  The number of data points {\tt data} needs not to be a power of 2.
  4044.  
  4045.  To be used with discernment!
  4046.  
  4047. \Syntax
  4048. \bq smooth {\it $\sigma$} {\it in-VECTOR} {\it out-VECTOR}\eq
  4049.  
  4050. \Seealso
  4051. \bq fft, invfft, cmode, C \eq
  4052.  
  4053. @ifhelp
  4054. ?special
  4055. @else
  4056. \section{special}
  4057. @endif
  4058.  
  4059.  The following special commands are left for debugging or macro purposes.
  4060.  They start with an underscore to avoid mistakes and remind of their
  4061.  special character.
  4062.  
  4063.  {\tt \_killplot} will kill the current plotting program.
  4064.  
  4065. \Syntax
  4066. \bq \_killplot \eq
  4067.  
  4068.  {\tt \_dumplot} will send the following vectors in the plotting
  4069.  program pipe. This is only useful if the current plotting program
  4070.  accept data from its stdin. {\tt \_dumplot} can accept up to 16
  4071.  arguments.
  4072.  
  4073. \Syntax
  4074. \bq \_dumplot {\it VECTOR-list}\eq
  4075.  
  4076. \Example
  4077. \bq \_dumplot X Y DY \eq
  4078.  
  4079. \Seealso
  4080. \bq macro, show macros, plot \eq
  4081.  
  4082. @ifhelp
  4083. ?spline
  4084. @else
  4085. \section{spline}
  4086. @endif
  4087.  
  4088.  The {\tt spline} function initializes the internal table for the
  4089.  calculation of interpolated values using cubic spline method.
  4090.  Interpolated values are obtained from calls to the C-calculator math
  4091.  function {\tt interp()}. The value of the first derivative at the
  4092.  first and last data points can be specified by optional arguments. If
  4093.  not specified, or if one of the optional arguments is an asterisk {\tt *},
  4094.  then a {\it natural} cubic spline is assumed in which case the
  4095.  interpolated curve is such that the second derivative at the extreme
  4096.  points (or one of them) is null. The asterisk is more likely to be used
  4097.  in cases where the user would like to specify the first derivative at
  4098.  the last point only. The independent vector must be such that its
  4099.  value increases monotonically.
  4100.  
  4101. \Syntax
  4102. \bq spline {\it indep-VECTOR} {\it dep-VECTOR} {\it y1\optio} {\it yn\optio}\eq
  4103.  
  4104. \Example
  4105. \nopagebreak\begin{verbatim}
  4106.      # Read vectors having a functional relation Y = F(X) from file "datafile"
  4107.      read datafile X:1 Y:2
  4108.      # Initialize the spline (as being natural)
  4109.      spline X Y
  4110.      # Save extreme values
  4111.      let from = X[1]; to = X[data]
  4112.      # Say there were data=10 points and you want 100
  4113.      set data 100
  4114.      # Rebuild X vector
  4115.      # First build X ranging [0, 1]
  4116.      let x=0; X=x++; tmp=data-1; X/=tmp
  4117.      # Then from 'from' to 'to': from + (to - from)*X
  4118.      let tmp=(to-from); X = from + X*tmp
  4119.      # Rebuild Y vector possibly containing original values as a subset
  4120.      let Y = interp(X)
  4121.      # Note that any value can be asked for
  4122.      let interp(2.34*pi)
  4123. \end{verbatim}
  4124.  
  4125. \Seealso
  4126. \bq math interp\eq
  4127.  
  4128. @ifhelp
  4129. ?startup
  4130. @else
  4131. \section{startup}
  4132. @endif
  4133.  
  4134.  If a file {\it .fudgitrc} exists in your home directory, it will be
  4135.  automatically loaded at startup time of the program. This is useful if
  4136.  one wants to include his own macros or have his own preferences loaded
  4137.  to \fudgit. This file is loaded for both interactive use ({\tt fudgit})
  4138.  and batch use ({\tt fudgit {\it script1} {\it script2}\ldots}).
  4139.  
  4140. \Examples
  4141. \nopagebreak\begin{verbatim}
  4142.      set plotting /usr/local/bin/sgiplot
  4143.      set prompt-pm ""
  4144.      set comment ?
  4145.      set samples 10000
  4146. \end{verbatim}
  4147.  
  4148.  A file called {\it .hist\_fudgit} is will be created in your home
  4149.  directory in order to keep history between calls of \fudgit. The
  4150.  number of events is determined at compilation time and defaults to 52.
  4151.  
  4152. \Seealso
  4153. \bq environment, alias, set plotting, set prompt \eq
  4154.  
  4155. @ifhelp
  4156. ?stop
  4157. @else
  4158. \section{stop}
  4159. @endif
  4160.  
  4161.  The command {\tt stop} is used to terminate a macro or a fitting
  4162.  function defined by the user. However, it can also be used in a script
  4163.  file in order to stop execution at a certain point. In this case, an
  4164.  warning message will report that {\tt stop} is being used outside a
  4165.  macro or function and the file from which the command was found will
  4166.  be considered as at the end of file (EOF).
  4167.  
  4168. \Seealso
  4169. \bq macro, set function \eq
  4170.  
  4171. @ifhelp
  4172. ?strings
  4173. ?Strings
  4174. @else
  4175. \section{string functions}
  4176. @endif
  4177.  
  4178.  \fudgit\ has a set of functions returning string objects. These are
  4179.  made available to deal with filename construction, or to read from
  4180.  standard input. To be consistent with string type, string functions
  4181.  are named with both lower case and upper case letters.
  4182.  
  4183.  Strings can be added or subtracted in the C-calculator mode. String
  4184.  addition {\it s1} + {\it s2} simply concatenates strings {\it s2} to
  4185.  string {\it s1}. String subtraction {\it s1} - {\it s2} removes {\it
  4186.  s2} from the end of {\it s1}. Note that the wild card `?' is supported
  4187.  in string subtractions.
  4188.  
  4189. @ifhelp
  4190. ?Strings DirName
  4191. ?strings DirName
  4192. ?DirName
  4193. @else
  4194. \subsection{string function DirName}
  4195. @endif
  4196.  The string function {\tt DirName} returns the directory name as extracted
  4197.  from the filename given as an argument.
  4198.  
  4199. \Syntax
  4200. \bq Dirname({\it String})\eq
  4201.  
  4202. \Seealso
  4203. \bq string functions FileName, Scan, Read\eq
  4204.  
  4205. @ifhelp
  4206. ?strings FileName
  4207. ?Strings FileName
  4208. ?FileName
  4209. @else
  4210. \subsection{string function FileName}
  4211. @endif
  4212.  
  4213.  The string function {\tt FileName} strips the leading directory names
  4214.  of the filename given as an argument. Note that the \unix\ command:
  4215. @ifhelp
  4216.  
  4217. @endif
  4218. \bq basename {\it File} {\it Extension}\eq
  4219. @ifhelp
  4220.  
  4221. @endif
  4222.  is equivalent to the \fudgit\ command:
  4223. @ifhelp
  4224.  
  4225. @endif
  4226. \bq FileName({\it File}) - {\it Extension}\eq
  4227. @ifhelp
  4228.  
  4229. @endif
  4230.  so that filename constructions can be made in {\tt foreach} loop
  4231.  for example.
  4232.  
  4233. \Syntax
  4234. \bq FileName({\it String})\eq
  4235.  
  4236. \Examples
  4237. \nopagebreak\begin{verbatim}
  4238.      foreach File in ls /usr/machin/data/*.32
  4239.          read $File X:1 Y:2{2:23}
  4240.          # Some commands
  4241.          .
  4242.          .
  4243.          # let File be the filename only, less the ".32" extension
  4244.          let File = FileName(File) - ".32"
  4245.          # And let Dir be the directory name
  4246.          let Dir = DirName(File)
  4247.      end
  4248. \end{verbatim}
  4249.  
  4250. \Seealso
  4251. \bq foreach, string functions, cmode, \$ \eq
  4252.  
  4253. @ifhelp
  4254. ?strings Read
  4255. ?Strings Read
  4256. ?Read
  4257. @else
  4258. \subsection{string function Read}
  4259. @endif
  4260.  
  4261.  The {\tt Read} function read a line from the file chosen by the {\tt
  4262.  set input} function, strips the newline character and returns the
  4263.  resulting string. If the input is {\tt stdin}, the user will be
  4264.  prompted by a {\it ?} and the program will stop until a non-null
  4265.  string is entered. This is most likely to be used in macros requiring
  4266.  some input during run time. The {\tt Read()} function can be used to
  4267.  read numbers with the help of {\tt scan()}. See the example below.
  4268.  
  4269.  {\tt Read} can also be used to build vectors by taking one every $n$
  4270.  points. This can be done by two imbedded {\tt for} loops.
  4271.  
  4272.  Note: The newline character is not passed to the string.
  4273.  
  4274. \Examples
  4275. \nopagebreak\begin{verbatim}
  4276.     # Read a string from stdin (the default)
  4277.     set input stdin
  4278.     let String = Read()
  4279.     # How to get a value out of a string: equivalent to vread()
  4280.     let value = scan(Read(), "\%lf") \eq
  4281.     # How to skip lines in a file
  4282.     # Read say file project/numbers.data
  4283.     set input project/numbers.data
  4284.     cmode
  4285.     for (i=1; i<=top; i++) {
  4286.         Line = Read()                            # Read one line
  4287.         X[i] = scan(Line, "%lf");                # get first column
  4288.         Y[i] = scan(Line, "%*lf %*lf %lf");        # get third column
  4289.         for (j=1; j<n; j++) {
  4290.             Line = Read()                        # Read n-1 lines
  4291.         }
  4292.     }
  4293.     fmode
  4294.     set input stdin
  4295. \end{verbatim}
  4296.  
  4297. \Seealso
  4298. \bq set input, math function scan, string functions, \$ \eq
  4299.  
  4300. @ifhelp
  4301. ?strings Scan
  4302. ?Scan
  4303. @else
  4304. \subsection{string function Scan}
  4305. @endif
  4306.  
  4307.  {\tt Scan({\it String, Format})} function returns a string as
  4308.  extracted from string {\it String} and according to string format {\it
  4309.  Format}. The format is built with the same rules {\tt sscanf} uses.
  4310.  See man pages on {\tt scanf(3)}. Note that the format must contain one
  4311.  active "\%s" or "\%[]" construction. An example might be of some help
  4312.  here, especially to show how to use {\tt Scan} in conjunction with
  4313.  C-calculator mode defined strings. {\tt Scan} is particularly helpful
  4314.  to extract parts of filenames. Recall that strings are defined by
  4315.  double quotes as in standard C.
  4316.  
  4317.  Knowing about the "\%[ ]" scanf(3) construction might be useful at
  4318.  this point. Consider the following few examples: {\tt "\%[a-zA-Z]"}
  4319.  means to read the longest string matched so that it is composed of any
  4320.  letter; {\tt "\%[\^{ }0-9]"} means to read the longest string matched
  4321.  so that it is NOT composed of any digit; {\tt "\%[\^{ }\_.]"} means to
  4322.  read the longest string matched so that it is not composed of
  4323.  characters `\_' or `.'.
  4324.  
  4325. \Examples
  4326. \nopagebreak\begin{verbatim}
  4327.      # define a string called Testname
  4328.      let Testname = "dummy25.dat"
  4329.      # Read until a point is encountered
  4330.      let Base = Scan(Testname, "%[^.]"))
  4331. \end{verbatim}
  4332.  
  4333. \Seealso
  4334. \bq \$, scan, string functions Read, DirName, FileName, C, cmode, quotes \eq
  4335.  
  4336. @ifhelp
  4337. ?system
  4338. @else
  4339. \section{system}
  4340. @endif
  4341.  
  4342.  When called with arguments, the {\tt system} command is equivalent to
  4343.  the `!' bang operator, so the remainder of the line will be given to a
  4344.  Bourne shell for execution. If {\tt system} has no argument, a shell
  4345.  (depending on environment variable SHELL) will be started.
  4346.  
  4347. \Syntax
  4348. \bq system {\it shell-commands\optio}\eq
  4349.  
  4350. \Seealso
  4351. \bq environment, !, shell \eq
  4352.  
  4353. @ifhelp
  4354. ?then
  4355. @else
  4356. \section{then}
  4357. @endif
  4358.  
  4359.  The {\tt then} keyword is required in the fitting mode {\tt if}
  4360.  constructions. Refer to the latter for details.
  4361.  
  4362. @ifhelp
  4363. ?unalias
  4364. @else
  4365. \section{unalias}
  4366. @endif
  4367.  
  4368.  The {\tt unalias} command unaliases any alias previously assigned
  4369.  by the {\tt alias} command.
  4370.  
  4371. \Syntax
  4372. \bq unalias {\it alias\_name} \eq
  4373.  
  4374. \Examples
  4375. \bq unalias date\\
  4376. unalias gnuplot \eq
  4377.  
  4378. \Seealso
  4379. \bq \&, alias, macro, unmacro, append, show \eq
  4380.  
  4381. @ifhelp
  4382. ?unlock
  4383. @else
  4384. \section{unlock}
  4385. @endif
  4386.  
  4387.  The {\tt unlock} command changes a constant into a variable and thus
  4388.  allows the user to change its value. This is particularly useful in
  4389.  functions and procedures needing to change the value of the {\tt data}
  4390.  constant. Unlocking {\tt data} gives the user complete freedom on the
  4391.  effective size of vectors. No check is done on {\tt data}
  4392.  assignments, and therefore assigning a value to {\tt data} that is
  4393.  superior to {\tt samples} will result in a program crash. For this
  4394.  reason, it is always safer to change {\tt data} using the {\tt set
  4395.  data} command. It is not an error to unlock a variable. A warning
  4396.  message will be given though. However, trying to unlock something else
  4397.  than a constant or variable will result in an error.
  4398.  
  4399. \Seealso
  4400. \bq lock, set data, set samples, cmode \eq
  4401.  
  4402. @ifhelp
  4403. ?unmacro
  4404. @else
  4405. \section{unmacro}
  4406. @endif
  4407.  
  4408.  The {\tt unmacro} command is the counterpart of {\tt macro}. It is
  4409.  used to undefine macros. As does {\tt free}, {\tt unmacro} accepts the
  4410.  ``@all'' string in which case all the macros will be erased and freed
  4411.  from memory.
  4412.  
  4413. \Syntax
  4414. \bq unmacro {\it macro-list} \\
  4415. unmacro @all \eq
  4416.  
  4417. \Examples
  4418. \nopagebreak\begin{verbatim}
  4419.      unmacro myplot
  4420.      unmacro @all
  4421. \end{verbatim}
  4422.  
  4423. \Seealso
  4424. \bq alias, unalias, append, show \eq
  4425.  
  4426. @ifhelp
  4427. ?version
  4428. @else
  4429. \section{version}
  4430. @endif
  4431.  
  4432.  The {\tt version} command displays the version number and the
  4433.  welcoming message of \fudgit.
  4434.  
  4435. @ifhelp
  4436. ?vi
  4437. ?editor
  4438. @else
  4439. \section{vi}
  4440. @endif
  4441.  
  4442.  The command {\tt vi} calls the editor. It is equivalent to
  4443.  {\tt !vi filename}. Note that wild cards are also recognized and
  4444.  expanded.
  4445.  
  4446. \Syntax
  4447. \bq vi {\it argument-list} \eq
  4448.  
  4449. \Examples
  4450. \nopagebreak\begin{verbatim}
  4451.      vi file
  4452.      vi test.*
  4453. \end{verbatim}
  4454.  
  4455. \Seealso
  4456. \bq !, system, alias, shell\eq
  4457.  
  4458. @ifhelp
  4459. ?while
  4460. ?loop
  4461. @else
  4462. \section{while}
  4463. @endif
  4464.  
  4465.  The {\tt while} command allows the user to construct controlled loops
  4466.  on a series of operations. However, \fudgit\ supports two kinds of
  4467.  {\tt while} constructions, one in the fitting mode and the other in
  4468.  the C-calculator mode.
  4469.  
  4470. @ifhelp
  4471. ?while cmode_style
  4472. @else
  4473. \subsection{C-calculator while}
  4474. @endif
  4475.  
  4476.  The C-calculator mode while construction has a syntax similar to
  4477.  that of standard C. In interactive mode, any new input line will be
  4478.  prompted with a ``n\{\ldots n\verb+\t+'' where `n' stands for the nesting
  4479.  level and `\verb+\t+' for a tab. Recall that {\it cmode-line-statement}
  4480.  means a string of semicolon separated C-calculator mode commands.
  4481.  
  4482. \Syntax
  4483. \bq while ({\it conditions}) {\it cmode-line-statement}\eq
  4484. @ifhelp
  4485.  
  4486. @endif
  4487.  or
  4488. @ifhelp
  4489.  
  4490. @endif
  4491. \bq while ({\it conditions})\\
  4492.     {\it cmode-line-statement}\eq
  4493. @ifhelp
  4494.  
  4495. @endif
  4496.  or
  4497. @ifhelp
  4498. \bq while ({\it conditions}) \{\\
  4499.      {\it cmode-statements}\\
  4500. \}\eq
  4501.  
  4502. \Example
  4503. \nopagebreak\begin{verbatim}
  4504.      read file X:1 Y:2
  4505.      let x=12;sum1=0;sum2=0
  4506.      while (x++<=100) {
  4507.          sum1 += X[x]+Y[x]
  4508.          sum2 += X[x]^2 + Y[x]^2
  4509.      }
  4510. \end{verbatim}
  4511.  
  4512. \Seealso
  4513. \bq C, break, continue, cmode, for, func, proc, auto, math \eq
  4514.  
  4515. @ifhelp
  4516. ?while fmode_style
  4517. @else
  4518. \subsection{Fitting mode while}
  4519. @endif
  4520.  
  4521.  The fitting mode {\tt while} is very similar to the C-shell
  4522.  {\tt while}. As for the {\tt if} construction, the difference remains
  4523.  in a broader range of operators available to the conditional
  4524.  statement and the fact that the variable expansion operator `\$' is
  4525.  not required.
  4526.  
  4527.  As for the {\tt foreach} construction, a {\tt end} keyword is
  4528.  required to indicate the end of the loop. Note that
  4529.  {\it fmode-statements} can also contain C-calculator mode commands
  4530.  (including cmode {\tt while} loops!). Recall that the conditional
  4531.  statement is a C-calculator mode expression.
  4532.  
  4533. \Syntax
  4534. \bq while({\it conditions})\\
  4535.      {\it fmode-statements}\\
  4536. end\eq
  4537.  
  4538. \Seealso
  4539. \bq foreach, if, cmode \eq
  4540.  
  4541. @ifhelp
  4542. ?Credits
  4543. @include ../Credits
  4544. @endif
  4545.  
  4546. @ifhelp
  4547. ?README
  4548. @include ../Copyrights
  4549. @endif
  4550.  
  4551.